mirror of
https://github.com/tiennm99/caro.git
synced 2026-09-02 14:20:02 +00:00
新增watch操作
This commit is contained in:
+17
-1
@@ -16,6 +16,7 @@ public class ClientEventListener_CODE_SHOW_OPTIONS_PVP extends ClientEventListen
|
||||
SimplePrinter.printNotice("1. Create Room");
|
||||
SimplePrinter.printNotice("2. Room List");
|
||||
SimplePrinter.printNotice("3. Join Room");
|
||||
SimplePrinter.printNotice("4. Watch Game");
|
||||
SimplePrinter.printNotice("Please enter the number of options (enter [BACK] return options list)");
|
||||
String line = SimpleWriter.write("pvp");
|
||||
|
||||
@@ -43,7 +44,22 @@ public class ClientEventListener_CODE_SHOW_OPTIONS_PVP extends ClientEventListen
|
||||
pushToServer(channel, ServerEventCode.CODE_ROOM_JOIN, String.valueOf(option));
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else if (choose == 4) {
|
||||
SimplePrinter.printNotice("Please enter the room id you want to watch (enter [BACK] return options list)");
|
||||
line = SimpleWriter.write("roomid");
|
||||
|
||||
if(line.equalsIgnoreCase("BACK")) {
|
||||
call(channel, data);
|
||||
}else {
|
||||
int option = OptionsUtils.getOptions(line);
|
||||
if(line == null || option < 1) {
|
||||
SimplePrinter.printNotice("Invalid options, please choose again:");
|
||||
call(channel, data);
|
||||
}else{
|
||||
pushToServer(channel, ServerEventCode.CODE_GAME_WATCH, String.valueOf(option));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SimplePrinter.printNotice("Invalid option, please choose again:");
|
||||
call(channel, data);
|
||||
}
|
||||
|
||||
+14
-1
@@ -1,6 +1,8 @@
|
||||
package org.nico.ratel.landlords.client.handler;
|
||||
|
||||
import org.nico.noson.Noson;
|
||||
import org.nico.ratel.landlords.channel.ChannelUtils;
|
||||
import org.nico.ratel.landlords.client.entity.User;
|
||||
import org.nico.ratel.landlords.client.event.ClientEventListener;
|
||||
import org.nico.ratel.landlords.entity.ClientTransferData.ClientTransferDataProtoc;
|
||||
import org.nico.ratel.landlords.enums.ClientEventCode;
|
||||
@@ -12,6 +14,9 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TransferHandler extends ChannelInboundHandlerAdapter{
|
||||
|
||||
@Override
|
||||
@@ -24,7 +29,15 @@ public class TransferHandler extends ChannelInboundHandlerAdapter{
|
||||
}
|
||||
ClientEventCode code = ClientEventCode.valueOf(clientTransferData.getCode());
|
||||
if(code != null) {
|
||||
ClientEventListener.get(code).call(ctx.channel(), clientTransferData.getData());
|
||||
if (User.INSTANCE.isWatching()) {
|
||||
Map<String, Object> wrapMap = new HashMap<>(3);
|
||||
wrapMap.put("code", code);
|
||||
wrapMap.put("data", clientTransferData.getData());
|
||||
|
||||
ClientEventListener.get(ClientEventCode.CODE_GAME_WATCH).call(ctx.channel(), Noson.reversal(wrapMap));
|
||||
} else {
|
||||
ClientEventListener.get(code).call(ctx.channel(), clientTransferData.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user