match & drop hero per
parent
195535617e
commit
885bdebaff
|
|
@ -0,0 +1,11 @@
|
|||
Id Content Priority
|
||||
int mut,int#int,2 int
|
||||
1 61#1000|62#1000 1
|
||||
2 61#1500|62#1500 2
|
||||
3 61#2000|62#2000 3
|
||||
4 61#2500|62#2500 4
|
||||
11 106#2000 99
|
||||
12 52#1000 99
|
||||
13 55#1000 99
|
||||
14 56#3000 99
|
||||
15 5#500 99
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
package com.ljsd.jieling.battle.actor;
|
||||
|
||||
public enum StateType {
|
||||
UNREADY_STATE(1),
|
||||
READYED_STATE(2),
|
||||
GAMING_STATE(3),
|
||||
FROZEN(4),
|
||||
MOVEABLE(5),
|
||||
|
||||
FROZEN(1),
|
||||
MOVEABLE(2),
|
||||
;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BloodyBattleMatchServer {
|
||||
public class BloodyBattleMatchServer implements IMatch{
|
||||
private static WaitingRoom waitingRoom = new WaitingRoom();
|
||||
private static Map<Integer,Integer> roomFull = new HashMap<>();
|
||||
static {
|
||||
|
|
@ -17,8 +17,9 @@ public class BloodyBattleMatchServer {
|
|||
}
|
||||
|
||||
|
||||
public static void tryMatch(int uid, int type){
|
||||
Room room = waitingRoom.findRoom(uid, type, new IMatch.IRoomMatchFilter() {
|
||||
@Override
|
||||
public void tryMatch(int uid, int type){
|
||||
Room room = waitingRoom.findRoom(type, new IMatch.IRoomMatchFilter() {
|
||||
@Override
|
||||
public Room filter(List<Room> rooms) {
|
||||
int full = roomFull.get(type);
|
||||
|
|
@ -39,11 +40,8 @@ public class BloodyBattleMatchServer {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
tryMatch(100000001,1);
|
||||
tryMatch(100000002,1);
|
||||
tryMatch(100000003,1);
|
||||
tryMatch(100000004,1);
|
||||
System.out.println();
|
||||
@Override
|
||||
public MatchType getMatchType() {
|
||||
return MatchType.RANDOM;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.ljsd.jieling.battle.room.Room;
|
|||
import java.util.List;
|
||||
|
||||
public interface IMatch {
|
||||
public void match();
|
||||
public void tryMatch(int uid, int type);
|
||||
|
||||
/**
|
||||
* @return 匹配的方式
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ljsd.jieling.battle.match;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.RoomProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MatchServerice {
|
||||
|
||||
private static Map<Integer,IMatch> matcherServerMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
matcherServerMap.put(1,new BloodyBattleMatchServer());
|
||||
}
|
||||
|
||||
//有用户加入时,同时做匹配
|
||||
//matchRule 匹配规则
|
||||
public static synchronized void addPlayer(ISession iSession, RoomProto.RoomMatchRequest request, int responseMsgId) throws Exception {
|
||||
User user = UserManager.getUserInMem(iSession.getUid());
|
||||
if(user.getRoomInfo().isMatching()){
|
||||
//已经在匹配队列中了
|
||||
MessageUtil.sendErrorResponse(iSession, 0, responseMsgId, "已经在匹配队列中了");
|
||||
return;
|
||||
}
|
||||
if(user.getRoomInfo().getRoomId() != -1){
|
||||
//已经在房间中了
|
||||
MessageUtil.sendErrorResponse(iSession, 0, responseMsgId, "已经在房间中了");
|
||||
return;
|
||||
}
|
||||
user.getRoomInfo().setMatching(true);
|
||||
IMatch iMatch = matcherServerMap.get(1);
|
||||
iMatch.tryMatch(iSession.getUid(),1);
|
||||
MessageUtil.sendRoomMatchResponse(iSession, responseMsgId, request.getType(), true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
package com.ljsd.jieling.battle.room;
|
||||
|
||||
import com.ljsd.jieling.battle.actor.*;
|
||||
import com.ljsd.jieling.protocols.SceneFight;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BeanToProto {
|
||||
|
||||
public static SceneFight.SceneActor getSceneActor(SceneActor sceneActor){
|
||||
public static CommonProto.SceneActor getSceneActor(SceneActor sceneActor){
|
||||
ActorType actorType = sceneActor.getType();
|
||||
SceneFight.SceneActor.Builder builder = SceneFight.SceneActor.newBuilder()
|
||||
CommonProto.SceneActor.Builder builder = CommonProto.SceneActor.newBuilder()
|
||||
.setId(sceneActor.getId())
|
||||
.setCurPos(sceneActor.getPos())
|
||||
.setType(actorType.getStateCode());
|
||||
|
|
@ -19,8 +19,8 @@ public class BeanToProto {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
public static SceneFight.Creature getCreature(Creature creature){
|
||||
return SceneFight.Creature.newBuilder()
|
||||
public static CommonProto.Creature getCreature(Creature creature){
|
||||
return CommonProto.Creature.newBuilder()
|
||||
.setCurHp(creature.getLife().getCurMp())
|
||||
.setMaxHp(creature.getLife().getMaxMp())
|
||||
.setSpeed(creature.getSpeed())
|
||||
|
|
@ -30,8 +30,8 @@ public class BeanToProto {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static SceneFight.ActorEffectBufferInfo getActorEffectBufferInfo(EffectBuffer effectBuffer){
|
||||
return SceneFight.ActorEffectBufferInfo.newBuilder()
|
||||
public static CommonProto.ActorEffectBufferInfo getActorEffectBufferInfo(EffectBuffer effectBuffer){
|
||||
return CommonProto.ActorEffectBufferInfo.newBuilder()
|
||||
.setId(effectBuffer.getId())
|
||||
.setStartTime((int)(effectBuffer.getStartTime()/1000))
|
||||
.setEndTime((int)(effectBuffer.getStartTime()/1000))
|
||||
|
|
@ -41,8 +41,8 @@ public class BeanToProto {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static SceneFight.SceneInfo getSceneInfo(Scene scene){
|
||||
SceneFight.SceneInfo.Builder builder = SceneFight.SceneInfo.newBuilder().setMapId(scene.getMapId());
|
||||
public static CommonProto.SceneInfo getSceneInfo(Scene scene){
|
||||
CommonProto.SceneInfo.Builder builder = CommonProto.SceneInfo.newBuilder().setMapId(scene.getMapId());
|
||||
Map<Integer, SceneActor> sceneActorMap = scene.getSceneActorMap();
|
||||
for(SceneActor sceneActor : sceneActorMap.values()){
|
||||
builder.addSceneActor(getSceneActor(sceneActor));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ljsd.jieling.battle.actor.Life;
|
|||
import com.ljsd.jieling.battle.actor.Scene;
|
||||
import com.ljsd.jieling.battle.actor.SceneMonster;
|
||||
import com.ljsd.jieling.battle.actor.ScenePlayer;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -16,12 +17,13 @@ public class SceneManager {
|
|||
|
||||
public static void createScene(Room room){
|
||||
Scene scene = new Scene();
|
||||
int i = 20;
|
||||
for(Integer uid : room.fightPlayer){
|
||||
ScenePlayer playerA = new ScenePlayer();
|
||||
playerA.setId(uid);
|
||||
playerA.setScene(scene);
|
||||
playerA.setLife(new Life(1000,1000));
|
||||
playerA.setPos(256*1+1);
|
||||
playerA.setPos(256*i+i);
|
||||
|
||||
scene.addScenActor(playerA);
|
||||
}
|
||||
|
|
@ -32,6 +34,7 @@ public class SceneManager {
|
|||
sceneMonster.setLife(new Life(1000,1000));
|
||||
|
||||
scheduledExecutor.execute(scene);
|
||||
MessageUtil.sendRoomMatchSuccessIndication(scene);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class WaitingRoom {
|
|||
|
||||
|
||||
|
||||
public static Room findRoom(int uid,int type, IMatch.IRoomMatchFilter filter){
|
||||
public static Room findRoom(int type, IMatch.IRoomMatchFilter filter){
|
||||
List<Room> rooms = roomByType.get(type);
|
||||
Room room = filter.filter(rooms);
|
||||
if(room!=null){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.ljsd.jieling.handler.map.missionProcessor;
|
||||
|
||||
import com.ljsd.jieling.config.SAccomplishmentConfig;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
public interface BaseMissionProcesor {
|
||||
|
||||
public int checkAndUpdateMissionProcessor(User user, SAccomplishmentConfig sAccomplishmentConfig, int eventId, int time);
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package com.ljsd.jieling.handler.room;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.room.RoomManager;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RoomGetInfoHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.ROOM_GET_FULL_INFO_REQEUST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
RoomManager.getRommInfo(iSession);
|
||||
}
|
||||
}
|
||||
|
|
@ -231,6 +231,7 @@ public class HeroLogic {
|
|||
if( (alreadyCount + perCount)/lotterySecurityReward[0] > alreadyCount/lotterySecurityReward[0]){
|
||||
builder.setExtraBox(ItemUtil.drop(user, new int[]{lotterySecurityReward[1]},1F,0,BIReason.HERO_RANDOM));
|
||||
}
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.RANDOM_HERO,sLotterySetting.getLotteryType(),perCount);
|
||||
}
|
||||
heroManager.updateRandCount(type,randCount);
|
||||
if(tenTimesMustGetItem!=null){
|
||||
|
|
@ -238,8 +239,8 @@ public class HeroLogic {
|
|||
dropHeroAndItem[j++] = tenTimesMustGetItem[i];
|
||||
}
|
||||
}
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.RANDOM_HERO,sLotterySetting.getLotteryType(),perCount);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropHeroAndItem,BIReason.HERO_RANDOM);
|
||||
|
||||
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, dropHeroAndItem,BIReason.HERO_RANDOM);
|
||||
builder.setDrop(drop);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,42 +132,11 @@ public class RoomManager {
|
|||
agentInfoList.add(agentInfoBuilder.build());
|
||||
}
|
||||
|
||||
MessageUtil.sendRoomMatchSuccessIndication(playerArray, room.getType(), roomId, 1, cells, agentInfoList);
|
||||
// MessageUtil.sendRoomMatchSuccessIndication(playerArray, room.getType(), roomId, 1, cells, agentInfoList);
|
||||
return room;
|
||||
}
|
||||
|
||||
public static void getRommInfo(ISession iSession) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int roomId = user.getRoomInfo().getRoomId();
|
||||
int responseMsgId = MessageTypeProto.MessageType.ROOM_GET_FULL_INFO_RESPONSE_VALUE;
|
||||
if(roomId == -1){
|
||||
MessageUtil.sendErrorResponse(iSession, 0, responseMsgId, "已经在房间中了");
|
||||
return;
|
||||
}
|
||||
Room room = getRoomById(roomId);
|
||||
if(room == null){
|
||||
MessageUtil.sendErrorResponse(iSession, 0, responseMsgId, "房间已销毁");
|
||||
return;
|
||||
}
|
||||
List<CommonProto.Cell> cells = new ArrayList<>();
|
||||
Map<Integer, RoomPlayerInfo> roomPlayers = room.getRoomPlayers();
|
||||
List<RoomProto.AgentInfo> agentInfoList = new ArrayList<>();
|
||||
for(RoomPlayerInfo roomPlayerInfo:roomPlayers.values()) {
|
||||
if(!roomPlayerInfo.getPath().isEmpty()){
|
||||
roomPlayerInfo.move(System.currentTimeMillis());
|
||||
}
|
||||
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
||||
agentInfoBuilder.setPlayerUid(roomPlayerInfo.getUid())
|
||||
.setCurHp(1000)
|
||||
.setMaxHp(1000)
|
||||
.setCamp(roomPlayerInfo.getCamp())
|
||||
.setCurXY(roomPlayerInfo.getCurPos())
|
||||
.addAllPath(roomPlayerInfo.getPath());
|
||||
agentInfoList.add(agentInfoBuilder.build());
|
||||
}
|
||||
MessageUtil.sendRoomInfoToPerson(iSession, room.getType(), roomId, 1, cells, agentInfoList);
|
||||
}
|
||||
|
||||
|
||||
public static synchronized Room getRoomById(int roomId) {
|
||||
return roomMap.get(roomId);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ package com.ljsd.jieling.util;
|
|||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.jieling.battle.actor.ActorType;
|
||||
import com.ljsd.jieling.battle.actor.Scene;
|
||||
import com.ljsd.jieling.battle.actor.SceneActor;
|
||||
import com.ljsd.jieling.battle.room.BeanToProto;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
|
|
@ -29,7 +33,7 @@ public class MessageUtil {
|
|||
backMessage = new byte[0];
|
||||
} else {
|
||||
backMessage = generatedMessage.toByteArray();
|
||||
// LOGGER.info(JsonFormat.printToString(generatedMessage));
|
||||
LOGGER.info(JsonFormat.printToString(generatedMessage));
|
||||
}
|
||||
|
||||
int length = PackageConstant.UID_FIELD_LEN + PackageConstant.TOKEN_LEN
|
||||
|
|
@ -230,38 +234,20 @@ public class MessageUtil {
|
|||
sendMessage(session, 1, responseMsgId, builder.build(), true);
|
||||
}
|
||||
|
||||
public static void sendRoomMatchSuccessIndication(int[] uids, int type, int roomId, int mapId,
|
||||
List<CommonProto.Cell> cellList, List<RoomProto.AgentInfo> agentInfoList) {
|
||||
public static void sendRoomMatchSuccessIndication(Scene scene) {
|
||||
RoomProto.RoomMatchSuccessIndication.Builder builder = RoomProto.RoomMatchSuccessIndication.newBuilder();
|
||||
builder.setRoomId(roomId);
|
||||
builder.setType(type);
|
||||
builder.setMapId(mapId);
|
||||
builder.addAllMapList(cellList);
|
||||
builder.addAllAgentInfos(agentInfoList);
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
builder.setTemporaryItems(dropBuilder.build());
|
||||
for(int uid : uids){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||
if(sessionByUid!=null){
|
||||
sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.ROOM_MATCH_SUCCESS_INDICATION_VALUE, builder.build(), true);
|
||||
CommonProto.SceneInfo sceneInfo = BeanToProto.getSceneInfo(scene);
|
||||
builder.setSceneInfo(sceneInfo);
|
||||
for(SceneActor sceneActor : scene.getSceneActorMap().values()){
|
||||
if(sceneActor.getType() == ActorType.Player){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(sceneActor.getId());
|
||||
if(sessionByUid!=null){
|
||||
sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.ROOM_MATCH_SUCCESS_INDICATION_VALUE, builder.build(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendRoomInfoToPerson(ISession session,int type, int roomId, int mapId,
|
||||
List<CommonProto.Cell> cellList, List<RoomProto.AgentInfo> agentInfoList){
|
||||
RoomProto.RoomMatchSuccessIndication.Builder builder = RoomProto.RoomMatchSuccessIndication.newBuilder();
|
||||
builder.setRoomId(roomId);
|
||||
builder.setType(type);
|
||||
builder.setMapId(mapId);
|
||||
builder.addAllMapList(cellList);
|
||||
builder.addAllAgentInfos(agentInfoList);
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
builder.setTemporaryItems(dropBuilder.build());
|
||||
RoomProto.RoomGetFullInfoResponse build = RoomProto.RoomGetFullInfoResponse.newBuilder().setRoomMatchSuccessIndication(builder.build()).build();
|
||||
sendMessage(session,1, MessageTypeProto.MessageType.ROOM_GET_FULL_INFO_RESPONSE_VALUE, build, true);
|
||||
|
||||
}
|
||||
|
||||
public static void sendRoomCancelMatchResponse(ISession session, int responseMsgId, int type, boolean result) {
|
||||
RoomProto.RoomMatchResponse.Builder builder = RoomProto.RoomMatchResponse.newBuilder();
|
||||
|
|
|
|||
Loading…
Reference in New Issue