diff --git a/net-client/pom.xml b/net-client/pom.xml index 6e57921d..f2d941ef 100644 --- a/net-client/pom.xml +++ b/net-client/pom.xml @@ -7,11 +7,11 @@ com.beverly.hills.money.gang daikombat-server - 16.0.0 + 17.0.0 net-client - 16.0.0 + 17.0.0 14 @@ -81,7 +81,7 @@ com.beverly.hills.money.gang schema - 16.0.0 + 17.0.0 diff --git a/net-client/src/main/java/com/beverly/hills/money/gang/bots/BotRunnable.java b/net-client/src/main/java/com/beverly/hills/money/gang/bots/BotRunnable.java index 6d2d5033..0a4f5945 100644 --- a/net-client/src/main/java/com/beverly/hills/money/gang/bots/BotRunnable.java +++ b/net-client/src/main/java/com/beverly/hills/money/gang/bots/BotRunnable.java @@ -48,7 +48,7 @@ public void run() { gameConnection.write(JoinGameCommand.newBuilder() .setPlayerName(Thread.currentThread().getName()) .setGameId(GAME_ID_TO_CONNECT) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setSkin(PlayerSkinColor.GREEN) .setVersion(ClientConfig.VERSION).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); diff --git a/net-client/src/main/java/com/beverly/hills/money/gang/handler/GameConnectionInitializer.java b/net-client/src/main/java/com/beverly/hills/money/gang/handler/GameConnectionInitializer.java index 0db27cba..3d33f024 100644 --- a/net-client/src/main/java/com/beverly/hills/money/gang/handler/GameConnectionInitializer.java +++ b/net-client/src/main/java/com/beverly/hills/money/gang/handler/GameConnectionInitializer.java @@ -75,7 +75,6 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { - LOG.info("Channel is active. Options {}", ctx.channel().config().getOptions()); super.channelActive(ctx); } diff --git a/pom.xml b/pom.xml index 8c527c75..60ec077a 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.beverly.hills.money.gang daikombat-server - 16.0.0 + 17.0.0 pom diff --git a/schema/pom.xml b/schema/pom.xml index e155e69d..eaad5989 100644 --- a/schema/pom.xml +++ b/schema/pom.xml @@ -7,11 +7,11 @@ com.beverly.hills.money.gang daikombat-server - 16.0.0 + 17.0.0 schema - 16.0.0 + 17.0.0 14 diff --git a/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommand.java b/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommand.java index 258008fd..7f96a0f6 100644 --- a/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommand.java +++ b/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommand.java @@ -17,6 +17,7 @@ private GetServerInfoCommand(com.google.protobuf.GeneratedMessageV3.Builder b super(builder); } private GetServerInfoCommand() { + playerClass_ = 0; } @java.lang.Override @@ -39,6 +40,32 @@ protected java.lang.Object newInstance( com.beverly.hills.money.gang.proto.GetServerInfoCommand.class, com.beverly.hills.money.gang.proto.GetServerInfoCommand.Builder.class); } + private int bitField0_; + public static final int PLAYERCLASS_FIELD_NUMBER = 1; + private int playerClass_ = 0; + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return Whether the playerClass field is set. + */ + @java.lang.Override public boolean hasPlayerClass() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return The enum numeric value on the wire for playerClass. + */ + @java.lang.Override public int getPlayerClassValue() { + return playerClass_; + } + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return The playerClass. + */ + @java.lang.Override public com.beverly.hills.money.gang.proto.PlayerClass getPlayerClass() { + com.beverly.hills.money.gang.proto.PlayerClass result = com.beverly.hills.money.gang.proto.PlayerClass.forNumber(playerClass_); + return result == null ? com.beverly.hills.money.gang.proto.PlayerClass.UNRECOGNIZED : result; + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -53,6 +80,9 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeEnum(1, playerClass_); + } getUnknownFields().writeTo(output); } @@ -62,6 +92,10 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, playerClass_); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -77,6 +111,10 @@ public boolean equals(final java.lang.Object obj) { } com.beverly.hills.money.gang.proto.GetServerInfoCommand other = (com.beverly.hills.money.gang.proto.GetServerInfoCommand) obj; + if (hasPlayerClass() != other.hasPlayerClass()) return false; + if (hasPlayerClass()) { + if (playerClass_ != other.playerClass_) return false; + } if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -88,6 +126,10 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); + if (hasPlayerClass()) { + hash = (37 * hash) + PLAYERCLASS_FIELD_NUMBER; + hash = (53 * hash) + playerClass_; + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -218,6 +260,8 @@ private Builder( @java.lang.Override public Builder clear() { super.clear(); + bitField0_ = 0; + playerClass_ = 0; return this; } @@ -244,10 +288,21 @@ public com.beverly.hills.money.gang.proto.GetServerInfoCommand build() { @java.lang.Override public com.beverly.hills.money.gang.proto.GetServerInfoCommand buildPartial() { com.beverly.hills.money.gang.proto.GetServerInfoCommand result = new com.beverly.hills.money.gang.proto.GetServerInfoCommand(this); + if (bitField0_ != 0) { buildPartial0(result); } onBuilt(); return result; } + private void buildPartial0(com.beverly.hills.money.gang.proto.GetServerInfoCommand result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.playerClass_ = playerClass_; + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + @java.lang.Override public Builder clone() { return super.clone(); @@ -292,6 +347,9 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(com.beverly.hills.money.gang.proto.GetServerInfoCommand other) { if (other == com.beverly.hills.money.gang.proto.GetServerInfoCommand.getDefaultInstance()) return this; + if (other.hasPlayerClass()) { + setPlayerClass(other.getPlayerClass()); + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -318,6 +376,11 @@ public Builder mergeFrom( case 0: done = true; break; + case 8: { + playerClass_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { done = true; // was an endgroup tag @@ -333,6 +396,67 @@ public Builder mergeFrom( } // finally return this; } + private int bitField0_; + + private int playerClass_ = 0; + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return Whether the playerClass field is set. + */ + @java.lang.Override public boolean hasPlayerClass() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return The enum numeric value on the wire for playerClass. + */ + @java.lang.Override public int getPlayerClassValue() { + return playerClass_; + } + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @param value The enum numeric value on the wire for playerClass to set. + * @return This builder for chaining. + */ + public Builder setPlayerClassValue(int value) { + playerClass_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return The playerClass. + */ + @java.lang.Override + public com.beverly.hills.money.gang.proto.PlayerClass getPlayerClass() { + com.beverly.hills.money.gang.proto.PlayerClass result = com.beverly.hills.money.gang.proto.PlayerClass.forNumber(playerClass_); + return result == null ? com.beverly.hills.money.gang.proto.PlayerClass.UNRECOGNIZED : result; + } + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @param value The playerClass to set. + * @return This builder for chaining. + */ + public Builder setPlayerClass(com.beverly.hills.money.gang.proto.PlayerClass value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + playerClass_ = value.getNumber(); + onChanged(); + return this; + } + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return This builder for chaining. + */ + public Builder clearPlayerClass() { + bitField0_ = (bitField0_ & ~0x00000001); + playerClass_ = 0; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommandOrBuilder.java b/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommandOrBuilder.java index 23c7ad69..db43d6b9 100644 --- a/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommandOrBuilder.java +++ b/schema/src/main/java/com/beverly/hills/money/gang/proto/GetServerInfoCommandOrBuilder.java @@ -7,4 +7,20 @@ public interface GetServerInfoCommandOrBuilder extends // @@protoc_insertion_point(interface_extends:daikombat.dto.GetServerInfoCommand) com.google.protobuf.MessageOrBuilder { + + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return Whether the playerClass field is set. + */ + boolean hasPlayerClass(); + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return The enum numeric value on the wire for playerClass. + */ + int getPlayerClassValue(); + /** + * optional .daikombat.dto.PlayerClass playerClass = 1; + * @return The playerClass. + */ + com.beverly.hills.money.gang.proto.PlayerClass getPlayerClass(); } diff --git a/schema/src/main/java/com/beverly/hills/money/gang/proto/PlayerClass.java b/schema/src/main/java/com/beverly/hills/money/gang/proto/PlayerClass.java index 5df651b1..3c46e9ea 100644 --- a/schema/src/main/java/com/beverly/hills/money/gang/proto/PlayerClass.java +++ b/schema/src/main/java/com/beverly/hills/money/gang/proto/PlayerClass.java @@ -10,40 +10,32 @@ public enum PlayerClass implements com.google.protobuf.ProtocolMessageEnum { /** - * COMMONER = 0; + * WARRIOR = 0; */ - COMMONER(0), + WARRIOR(0), /** - * DRACULA_BERSERK = 1; + * ANGRY_SKELETON = 1; */ - DRACULA_BERSERK(1), + ANGRY_SKELETON(1), /** * DEMON_TANK = 2; */ DEMON_TANK(2), - /** - * BEAST_WARRIOR = 3; - */ - BEAST_WARRIOR(3), UNRECOGNIZED(-1), ; /** - * COMMONER = 0; + * WARRIOR = 0; */ - public static final int COMMONER_VALUE = 0; + public static final int WARRIOR_VALUE = 0; /** - * DRACULA_BERSERK = 1; + * ANGRY_SKELETON = 1; */ - public static final int DRACULA_BERSERK_VALUE = 1; + public static final int ANGRY_SKELETON_VALUE = 1; /** * DEMON_TANK = 2; */ public static final int DEMON_TANK_VALUE = 2; - /** - * BEAST_WARRIOR = 3; - */ - public static final int BEAST_WARRIOR_VALUE = 3; public final int getNumber() { @@ -70,10 +62,9 @@ public static PlayerClass valueOf(int value) { */ public static PlayerClass forNumber(int value) { switch (value) { - case 0: return COMMONER; - case 1: return DRACULA_BERSERK; + case 0: return WARRIOR; + case 1: return ANGRY_SKELETON; case 2: return DEMON_TANK; - case 3: return BEAST_WARRIOR; default: return null; } } diff --git a/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommandOuterClass.java b/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommandOuterClass.java index 517669ee..24baf364 100644 --- a/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommandOuterClass.java +++ b/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommandOuterClass.java @@ -78,42 +78,44 @@ public static void registerAllExtensions( "mandH\000\0227\n\016respawnCommand\030\010 \001(\0132\035.daikomb" + "at.dto.RespawnCommandH\000\022G\n\026mergeConnecti" + "onCommand\030\t \001(\0132%.daikombat.dto.MergeCon" + - "nectionCommandH\000B\t\n\007commandB\007\n\005_hmac\"\026\n\024" + - "GetServerInfoCommand\"\r\n\013PingCommand\"|\n\024P" + - "ushChatEventCommand\022\023\n\006gameId\030\001 \001(\005H\000\210\001\001" + - "\022\024\n\007message\030\002 \001(\tH\001\210\001\001\022\025\n\010playerId\030\003 \001(\005" + - "H\002\210\001\001B\t\n\007_gameIdB\n\n\010_messageB\013\n\t_playerI" + - "d\"\261\002\n\017JoinGameCommand\022\023\n\006gameId\030\001 \001(\005H\000\210" + - "\001\001\022\024\n\007version\030\002 \001(\tH\001\210\001\001\022\027\n\nplayerName\030\003" + - " \001(\tH\002\210\001\001\0221\n\004skin\030\004 \001(\0162\036.daikombat.dto." + - "PlayerSkinColorH\003\210\001\001\022\035\n\020recoveryPlayerId" + - "\030\005 \001(\005H\004\210\001\001\0224\n\013playerClass\030\006 \001(\0162\032.daiko" + - "mbat.dto.PlayerClassH\005\210\001\001B\t\n\007_gameIdB\n\n\010" + - "_versionB\r\n\013_playerNameB\007\n\005_skinB\023\n\021_rec" + - "overyPlayerIdB\016\n\014_playerClass\"\\\n\026MergeCo" + - "nnectionCommand\022\023\n\006gameId\030\001 \001(\005H\000\210\001\001\022\025\n\010" + - "playerId\030\002 \001(\005H\001\210\001\001B\t\n\007_gameIdB\013\n\t_playe" + - "rId\"T\n\016RespawnCommand\022\023\n\006gameId\030\001 \001(\005H\000\210" + - "\001\001\022\025\n\010playerId\030\002 \001(\005H\001\210\001\001B\t\n\007_gameIdB\013\n\t" + - "_playerId\"\246\005\n\024PushGameEventCommand\022\023\n\006ga" + - "meId\030\001 \001(\005H\000\210\001\001\022I\n\teventType\030\002 \001(\01621.dai" + - "kombat.dto.PushGameEventCommand.GameEven" + - "tTypeH\001\210\001\001\022,\n\010position\030\003 \001(\0132\025.daikombat" + - ".dto.VectorH\002\210\001\001\022-\n\tdirection\030\004 \001(\0132\025.da" + - "ikombat.dto.VectorH\003\210\001\001\022\025\n\010playerId\030\005 \001(" + - "\005H\004\210\001\001\022\035\n\020affectedPlayerId\030\006 \001(\005H\005\210\001\001\022\025\n" + - "\010sequence\030\007 \001(\005H\006\210\001\001\022\024\n\007pingMls\030\010 \001(\005H\007\210" + - "\001\001\022\027\n\nteleportId\030\t \001(\005H\010\210\001\001\0222\n\nweaponTyp" + - "e\030\n \001(\0162\031.daikombat.dto.WeaponTypeH\t\210\001\001\"" + - "\223\001\n\rGameEventType\022\010\n\004MOVE\020\000\022\n\n\006ATTACK\020\001\022" + - "\030\n\024QUAD_DAMAGE_POWER_UP\020\002\022\031\n\025INVISIBILIT" + - "Y_POWER_UP\020\003\022\024\n\020DEFENCE_POWER_UP\020\004\022\014\n\010TE" + - "LEPORT\020\005\022\023\n\017HEALTH_POWER_UP\020\006B\t\n\007_gameId" + - "B\014\n\n_eventTypeB\013\n\t_positionB\014\n\n_directio" + - "nB\013\n\t_playerIdB\023\n\021_affectedPlayerIdB\013\n\t_" + - "sequenceB\n\n\010_pingMlsB\r\n\013_teleportIdB\r\n\013_" + - "weaponTypeB&\n\"com.beverly.hills.money.ga" + - "ng.protoP\001b\006proto3" + "nectionCommandH\000B\t\n\007commandB\007\n\005_hmac\"\\\n\024" + + "GetServerInfoCommand\0224\n\013playerClass\030\001 \001(" + + "\0162\032.daikombat.dto.PlayerClassH\000\210\001\001B\016\n\014_p" + + "layerClass\"\r\n\013PingCommand\"|\n\024PushChatEve" + + "ntCommand\022\023\n\006gameId\030\001 \001(\005H\000\210\001\001\022\024\n\007messag" + + "e\030\002 \001(\tH\001\210\001\001\022\025\n\010playerId\030\003 \001(\005H\002\210\001\001B\t\n\007_" + + "gameIdB\n\n\010_messageB\013\n\t_playerId\"\261\002\n\017Join" + + "GameCommand\022\023\n\006gameId\030\001 \001(\005H\000\210\001\001\022\024\n\007vers" + + "ion\030\002 \001(\tH\001\210\001\001\022\027\n\nplayerName\030\003 \001(\tH\002\210\001\001\022" + + "1\n\004skin\030\004 \001(\0162\036.daikombat.dto.PlayerSkin" + + "ColorH\003\210\001\001\022\035\n\020recoveryPlayerId\030\005 \001(\005H\004\210\001" + + "\001\0224\n\013playerClass\030\006 \001(\0162\032.daikombat.dto.P" + + "layerClassH\005\210\001\001B\t\n\007_gameIdB\n\n\010_versionB\r" + + "\n\013_playerNameB\007\n\005_skinB\023\n\021_recoveryPlaye" + + "rIdB\016\n\014_playerClass\"\\\n\026MergeConnectionCo" + + "mmand\022\023\n\006gameId\030\001 \001(\005H\000\210\001\001\022\025\n\010playerId\030\002" + + " \001(\005H\001\210\001\001B\t\n\007_gameIdB\013\n\t_playerId\"T\n\016Res" + + "pawnCommand\022\023\n\006gameId\030\001 \001(\005H\000\210\001\001\022\025\n\010play" + + "erId\030\002 \001(\005H\001\210\001\001B\t\n\007_gameIdB\013\n\t_playerId\"" + + "\246\005\n\024PushGameEventCommand\022\023\n\006gameId\030\001 \001(\005" + + "H\000\210\001\001\022I\n\teventType\030\002 \001(\01621.daikombat.dto" + + ".PushGameEventCommand.GameEventTypeH\001\210\001\001" + + "\022,\n\010position\030\003 \001(\0132\025.daikombat.dto.Vecto" + + "rH\002\210\001\001\022-\n\tdirection\030\004 \001(\0132\025.daikombat.dt" + + "o.VectorH\003\210\001\001\022\025\n\010playerId\030\005 \001(\005H\004\210\001\001\022\035\n\020" + + "affectedPlayerId\030\006 \001(\005H\005\210\001\001\022\025\n\010sequence\030" + + "\007 \001(\005H\006\210\001\001\022\024\n\007pingMls\030\010 \001(\005H\007\210\001\001\022\027\n\ntele" + + "portId\030\t \001(\005H\010\210\001\001\0222\n\nweaponType\030\n \001(\0162\031." + + "daikombat.dto.WeaponTypeH\t\210\001\001\"\223\001\n\rGameEv" + + "entType\022\010\n\004MOVE\020\000\022\n\n\006ATTACK\020\001\022\030\n\024QUAD_DA" + + "MAGE_POWER_UP\020\002\022\031\n\025INVISIBILITY_POWER_UP" + + "\020\003\022\024\n\020DEFENCE_POWER_UP\020\004\022\014\n\010TELEPORT\020\005\022\023" + + "\n\017HEALTH_POWER_UP\020\006B\t\n\007_gameIdB\014\n\n_event" + + "TypeB\013\n\t_positionB\014\n\n_directionB\013\n\t_play" + + "erIdB\023\n\021_affectedPlayerIdB\013\n\t_sequenceB\n" + + "\n\010_pingMlsB\r\n\013_teleportIdB\r\n\013_weaponType" + + "B&\n\"com.beverly.hills.money.gang.protoP\001" + + "b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -131,7 +133,7 @@ public static void registerAllExtensions( internal_static_daikombat_dto_GetServerInfoCommand_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_daikombat_dto_GetServerInfoCommand_descriptor, - new java.lang.String[] { }); + new java.lang.String[] { "PlayerClass", }); internal_static_daikombat_dto_PingCommand_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_daikombat_dto_PingCommand_fieldAccessorTable = new diff --git a/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommon.java b/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommon.java index 8f595230..fe67adc6 100644 --- a/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommon.java +++ b/schema/src/main/java/com/beverly/hills/money/gang/proto/ServerCommon.java @@ -35,10 +35,10 @@ public static void registerAllExtensions( "WeaponType\022\t\n\005PUNCH\020\000\022\013\n\007SHOTGUN\020\001\022\013\n\007RA" + "ILGUN\020\002\022\013\n\007MINIGUN\020\003*T\n\017PlayerSkinColor\022" + "\t\n\005GREEN\020\000\022\010\n\004PINK\020\001\022\n\n\006PURPLE\020\002\022\010\n\004BLUE" + - "\020\003\022\n\n\006YELLOW\020\004\022\n\n\006ORANGE\020\005*S\n\013PlayerClas" + - "s\022\014\n\010COMMONER\020\000\022\023\n\017DRACULA_BERSERK\020\001\022\016\n\n" + - "DEMON_TANK\020\002\022\021\n\rBEAST_WARRIOR\020\003B&\n\"com.b" + - "everly.hills.money.gang.protoP\001b\006proto3" + "\020\003\022\n\n\006YELLOW\020\004\022\n\n\006ORANGE\020\005*>\n\013PlayerClas" + + "s\022\013\n\007WARRIOR\020\000\022\022\n\016ANGRY_SKELETON\020\001\022\016\n\nDE" + + "MON_TANK\020\002B&\n\"com.beverly.hills.money.ga" + + "ng.protoP\001b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, diff --git a/schema/src/main/resources/server-command.proto b/schema/src/main/resources/server-command.proto index 109ada86..e6d0ebce 100644 --- a/schema/src/main/resources/server-command.proto +++ b/schema/src/main/resources/server-command.proto @@ -20,7 +20,9 @@ message ServerCommand { } } -message GetServerInfoCommand {} +message GetServerInfoCommand { + optional PlayerClass playerClass = 1; +} message PingCommand {} diff --git a/schema/src/main/resources/server-common.proto b/schema/src/main/resources/server-common.proto index d0510d78..1c977a79 100644 --- a/schema/src/main/resources/server-common.proto +++ b/schema/src/main/resources/server-common.proto @@ -23,10 +23,9 @@ enum PlayerSkinColor { } enum PlayerClass{ - COMMONER = 0; - DRACULA_BERSERK = 1; + WARRIOR = 0; + ANGRY_SKELETON = 1; DEMON_TANK = 2; - BEAST_WARRIOR = 3; } diff --git a/server/pom.xml b/server/pom.xml index f741f777..911465e6 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -7,11 +7,11 @@ com.beverly.hills.money.gang daikombat-server - 16.0.0 + 17.0.0 server - 16.0.0 + 17.0.0 14 @@ -92,7 +92,7 @@ com.beverly.hills.money.gang schema - 16.0.0 + 17.0.0 eu.rekawek.toxiproxy @@ -138,7 +138,7 @@ com.beverly.hills.money.gang net-client - 16.0.0 + 17.0.0 test diff --git a/server/src/main/java/com/beverly/hills/money/gang/config/ServerConfig.java b/server/src/main/java/com/beverly/hills/money/gang/config/ServerConfig.java index 51ed43c7..ca4605eb 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/config/ServerConfig.java +++ b/server/src/main/java/com/beverly/hills/money/gang/config/ServerConfig.java @@ -22,7 +22,7 @@ public interface ServerConfig { int PLAYER_SPEED_CHECK_FREQUENCY_MLS = NumberUtils.toInt( System.getenv("GAME_SERVER_PLAYER_SPEED_CHECK_FREQUENCY_MLS"), 10_000); - int PLAYER_SPEED = NumberUtils.toInt(System.getenv("GAME_SERVER_PLAYER_SPEED"), 5); + int PLAYER_SPEED = NumberUtils.toInt(System.getenv("GAME_SERVER_PLAYER_SPEED"), 6); int MAX_IDLE_TIME_MLS = NumberUtils.toInt(System.getenv("GAME_SERVER_MAX_IDLE_TIME_MLS"), 10_000); int DEFAULT_SHOTGUN_DAMAGE = NumberUtils.toInt( diff --git a/server/src/main/java/com/beverly/hills/money/gang/state/RPGStatsFactory.java b/server/src/main/java/com/beverly/hills/money/gang/factory/RPGStatsFactory.java similarity index 76% rename from server/src/main/java/com/beverly/hills/money/gang/state/RPGStatsFactory.java rename to server/src/main/java/com/beverly/hills/money/gang/factory/RPGStatsFactory.java index b5c1ce97..f6fa0eea 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/state/RPGStatsFactory.java +++ b/server/src/main/java/com/beverly/hills/money/gang/factory/RPGStatsFactory.java @@ -1,7 +1,11 @@ -package com.beverly.hills.money.gang.state; +package com.beverly.hills.money.gang.factory; import static com.beverly.hills.money.gang.state.entity.PlayerState.VAMPIRE_HP_BOOST; +import com.beverly.hills.money.gang.state.AttackType; +import com.beverly.hills.money.gang.state.PlayerRPGStatType; +import com.beverly.hills.money.gang.state.PlayerRPGStatValue; +import com.beverly.hills.money.gang.state.PlayerRPGStats; import com.beverly.hills.money.gang.state.entity.AttackStats; import com.beverly.hills.money.gang.state.entity.RPGPlayerClass; import java.util.Map; @@ -11,25 +15,25 @@ public class RPGStatsFactory { public static PlayerRPGStats create(RPGPlayerClass playerClass) { return switch (playerClass) { - case COMMONER -> createDefault(); - case TANK -> createTank(); - case BERSERK -> createBerserk(); - case WARRIOR -> createWarrior(); + case WARRIOR -> createDefault(); + case DEMON_TANK -> createTank(); + case ANGRY_SKELETON -> createAngrySkeleton(); }; } - // COMMONER + // WARRIOR private static PlayerRPGStats createDefault() { return PlayerRPGStats.defaultStats(); } - // DRACULA BERSERK - private static PlayerRPGStats createBerserk() { + // ANGRY SKELETON + private static PlayerRPGStats createAngrySkeleton() { return new PlayerRPGStats(Map.of( PlayerRPGStatType.ATTACK, PlayerRPGStatValue.createMax(), PlayerRPGStatType.DEFENSE, PlayerRPGStatValue.createMin(), - PlayerRPGStatType.VAMPIRISM, PlayerRPGStatValue.createDefault())); + PlayerRPGStatType.VAMPIRISM, PlayerRPGStatValue.createDefault(), + PlayerRPGStatType.GUN_SPEED, PlayerRPGStatValue.createMax())); } // DEMON TANK @@ -37,16 +41,8 @@ private static PlayerRPGStats createTank() { return new PlayerRPGStats(Map.of( PlayerRPGStatType.ATTACK, PlayerRPGStatValue.createDefault(), PlayerRPGStatType.DEFENSE, PlayerRPGStatValue.createMax(), - PlayerRPGStatType.VAMPIRISM, PlayerRPGStatValue.createMin())); - } - - - // BEAST WARRIOR - private static PlayerRPGStats createWarrior() { - return new PlayerRPGStats(Map.of( - PlayerRPGStatType.ATTACK, PlayerRPGStatValue.createMax(), - PlayerRPGStatType.DEFENSE, PlayerRPGStatValue.createDefault(), - PlayerRPGStatType.VAMPIRISM, PlayerRPGStatValue.createMin())); + PlayerRPGStatType.VAMPIRISM, PlayerRPGStatValue.createMin(), + PlayerRPGStatType.GUN_SPEED, PlayerRPGStatValue.createDefault())); } public static void main(String[] args) { diff --git a/server/src/main/java/com/beverly/hills/money/gang/factory/response/ServerResponseFactory.java b/server/src/main/java/com/beverly/hills/money/gang/factory/response/ServerResponseFactory.java index ccf28221..ac4a647e 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/factory/response/ServerResponseFactory.java +++ b/server/src/main/java/com/beverly/hills/money/gang/factory/response/ServerResponseFactory.java @@ -256,11 +256,18 @@ static PlayerSkinColor createPlayerSkinColor(PlayerStateColor color) { static PlayerClass createPlayerClass(RPGPlayerClass rpgPlayerClass) { return switch (rpgPlayerClass) { - case COMMONER -> PlayerClass.COMMONER; - case BERSERK -> PlayerClass.DRACULA_BERSERK; - case TANK -> PlayerClass.DEMON_TANK; - case WARRIOR -> PlayerClass.BEAST_WARRIOR; + case ANGRY_SKELETON -> PlayerClass.ANGRY_SKELETON; + case DEMON_TANK -> PlayerClass.DEMON_TANK; + case WARRIOR -> PlayerClass.WARRIOR; + }; + } + static RPGPlayerClass getRPGPlayerClass(PlayerClass playerClass) { + return switch (playerClass) { + case ANGRY_SKELETON -> RPGPlayerClass.ANGRY_SKELETON; + case DEMON_TANK -> RPGPlayerClass.DEMON_TANK; + case WARRIOR -> RPGPlayerClass.WARRIOR; + default -> throw new IllegalArgumentException("Not supported player class"); }; } diff --git a/server/src/main/java/com/beverly/hills/money/gang/handler/command/GetServerInfoCommandHandler.java b/server/src/main/java/com/beverly/hills/money/gang/handler/command/GetServerInfoCommandHandler.java index 4a31e07d..113fc061 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/handler/command/GetServerInfoCommandHandler.java +++ b/server/src/main/java/com/beverly/hills/money/gang/handler/command/GetServerInfoCommandHandler.java @@ -1,13 +1,13 @@ package com.beverly.hills.money.gang.handler.command; import static com.beverly.hills.money.gang.factory.response.ServerResponseFactory.createServerInfo; -import static com.beverly.hills.money.gang.state.entity.AttackStats.ATTACKS_INFO; +import static com.beverly.hills.money.gang.factory.response.ServerResponseFactory.getRPGPlayerClass; -import com.beverly.hills.money.gang.cheat.AntiCheat; import com.beverly.hills.money.gang.config.ServerConfig; import com.beverly.hills.money.gang.proto.ServerCommand; import com.beverly.hills.money.gang.proto.ServerCommand.CommandCase; import com.beverly.hills.money.gang.registry.GameRoomRegistry; +import com.beverly.hills.money.gang.state.entity.AttackStats; import io.netty.channel.Channel; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -28,7 +28,7 @@ public class GetServerInfoCommandHandler extends ServerCommandHandler { @Override protected boolean isValidCommand(ServerCommand msg, Channel currentChannel) { - return true; + return msg.getGetServerInfoCommand().hasPlayerClass(); } @Override @@ -37,7 +37,7 @@ protected void handleInternal(ServerCommand msg, Channel currentChannel) { ServerConfig.VERSION, gameRoomRegistry.getGames().map(game -> game), ServerConfig.FRAGS_PER_GAME, - ATTACKS_INFO, + AttackStats.getAttacksInfo(getRPGPlayerClass(msg.getGetServerInfoCommand().getPlayerClass())), ServerConfig.MOVES_UPDATE_FREQUENCY_MLS, ServerConfig.PLAYER_SPEED)); } diff --git a/server/src/main/java/com/beverly/hills/money/gang/handler/command/JoinGameServerCommandHandler.java b/server/src/main/java/com/beverly/hills/money/gang/handler/command/JoinGameServerCommandHandler.java index a402cda4..a078cbd2 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/handler/command/JoinGameServerCommandHandler.java +++ b/server/src/main/java/com/beverly/hills/money/gang/handler/command/JoinGameServerCommandHandler.java @@ -5,6 +5,7 @@ import static com.beverly.hills.money.gang.factory.response.ServerResponseFactory.createPowerUpSpawn; import static com.beverly.hills.money.gang.factory.response.ServerResponseFactory.createSpawnEventAllPlayers; import static com.beverly.hills.money.gang.factory.response.ServerResponseFactory.createTeleportSpawn; +import static com.beverly.hills.money.gang.factory.response.ServerResponseFactory.getRPGPlayerClass; import com.beverly.hills.money.gang.config.ServerConfig; import com.beverly.hills.money.gang.exception.GameErrorCode; @@ -101,15 +102,6 @@ private PlayerStateColor getSkinColor(PlayerSkinColor skinColorSelection) { }; } - private RPGPlayerClass getRPGPlayerClass(PlayerClass playerClass) { - return switch (playerClass) { - case COMMONER -> RPGPlayerClass.COMMONER; - case DRACULA_BERSERK -> RPGPlayerClass.BERSERK; - case BEAST_WARRIOR -> RPGPlayerClass.WARRIOR; - case DEMON_TANK -> RPGPlayerClass.TANK; - default -> throw new IllegalArgumentException("Not supported player class"); - }; - } protected void sendOtherSpawns( Game game, PlayerStateChannel joinedPlayerStateChannel, diff --git a/server/src/main/java/com/beverly/hills/money/gang/handler/inbound/GameServerInboundHandler.java b/server/src/main/java/com/beverly/hills/money/gang/handler/inbound/GameServerInboundHandler.java index 63c46bc0..26e0ceb3 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/handler/inbound/GameServerInboundHandler.java +++ b/server/src/main/java/com/beverly/hills/money/gang/handler/inbound/GameServerInboundHandler.java @@ -58,7 +58,6 @@ public GameServerInboundHandler(ServerTransport serverTransport, @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { serverTransport.setExtraTCPOptions(ctx.channel().config()); - LOG.info("Channel is active. Options {}", ctx.channel().config().getOptions()); super.channelActive(ctx); } diff --git a/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStatType.java b/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStatType.java index 0fabceaf..02baa7a8 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStatType.java +++ b/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStatType.java @@ -2,6 +2,6 @@ public enum PlayerRPGStatType { - ATTACK, DEFENSE, VAMPIRISM + ATTACK, DEFENSE, VAMPIRISM, GUN_SPEED } diff --git a/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStats.java b/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStats.java index ae804c6e..1aaa62a8 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStats.java +++ b/server/src/main/java/com/beverly/hills/money/gang/state/PlayerRPGStats.java @@ -3,12 +3,14 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import lombok.Getter; public class PlayerRPGStats { private final Map stats = new ConcurrentHashMap<>(); - public PlayerRPGStats(Map stats) { + public PlayerRPGStats( + Map stats) { if (stats.size() != PlayerRPGStatType.values().length) { throw new IllegalArgumentException("Not all RPG stats are specified"); } diff --git a/server/src/main/java/com/beverly/hills/money/gang/state/entity/AttackStats.java b/server/src/main/java/com/beverly/hills/money/gang/state/entity/AttackStats.java index f57d70e1..228d9070 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/state/entity/AttackStats.java +++ b/server/src/main/java/com/beverly/hills/money/gang/state/entity/AttackStats.java @@ -1,8 +1,11 @@ package com.beverly.hills.money.gang.state.entity; import com.beverly.hills.money.gang.config.ServerConfig; +import com.beverly.hills.money.gang.factory.RPGStatsFactory; import com.beverly.hills.money.gang.state.AttackType; +import com.beverly.hills.money.gang.state.PlayerRPGStatType; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -27,7 +30,7 @@ public class AttackStats { AttackType.RAILGUN, ServerConfig.DEFAULT_RAILGUN_DAMAGE, AttackType.MINIGUN, ServerConfig.DEFAULT_MINIGUN_DAMAGE); - public static final List ATTACKS_INFO; + private static final Map> ATTACKS_INFO = new HashMap<>(); static { if (MAX_ATTACK_DISTANCE.size() != AttackType.values().length) { @@ -40,14 +43,23 @@ public class AttackStats { throw new IllegalStateException("Not all attack types have damage configured"); } - ATTACKS_INFO = Arrays.stream(AttackType.values()).map( - attackType -> AttackInfo - .builder() - .attackType(attackType) - .delayMls(ATTACK_DELAY_MLS.get(attackType)) - .maxDistance(MAX_ATTACK_DISTANCE.get(attackType)) - .defaultDamage(ATTACK_DAMAGE.get(attackType)) - .build()) - .collect(Collectors.toList()); + Arrays.stream(RPGPlayerClass.values()).forEach(playerClass -> { + var gunSpeed = RPGStatsFactory.create(playerClass) + .getNormalized(PlayerRPGStatType.GUN_SPEED); + var info = Arrays.stream(AttackType.values()).map( + attackType -> AttackInfo + .builder() + .attackType(attackType) + .delayMls(Math.max((int) (ATTACK_DELAY_MLS.get(attackType) / gunSpeed), 150)) + .maxDistance(MAX_ATTACK_DISTANCE.get(attackType)) + .defaultDamage(ATTACK_DAMAGE.get(attackType)) + .build()) + .collect(Collectors.toList()); + ATTACKS_INFO.put(playerClass, info); + }); + } + + public static List getAttacksInfo(RPGPlayerClass playerClass) { + return ATTACKS_INFO.get(playerClass); } } diff --git a/server/src/main/java/com/beverly/hills/money/gang/state/entity/PlayerState.java b/server/src/main/java/com/beverly/hills/money/gang/state/entity/PlayerState.java index 20ed87bf..03aa8834 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/state/entity/PlayerState.java +++ b/server/src/main/java/com/beverly/hills/money/gang/state/entity/PlayerState.java @@ -11,7 +11,7 @@ import com.beverly.hills.money.gang.state.PlayerRPGStatType; import com.beverly.hills.money.gang.state.PlayerRPGStats; import com.beverly.hills.money.gang.state.PlayerStateReader; -import com.beverly.hills.money.gang.state.RPGStatsFactory; +import com.beverly.hills.money.gang.factory.RPGStatsFactory; import com.google.common.util.concurrent.AtomicDouble; import java.util.ArrayList; import java.util.List; diff --git a/server/src/main/java/com/beverly/hills/money/gang/state/entity/RPGPlayerClass.java b/server/src/main/java/com/beverly/hills/money/gang/state/entity/RPGPlayerClass.java index 3307f1e0..d0da23ca 100644 --- a/server/src/main/java/com/beverly/hills/money/gang/state/entity/RPGPlayerClass.java +++ b/server/src/main/java/com/beverly/hills/money/gang/state/entity/RPGPlayerClass.java @@ -1,6 +1,5 @@ package com.beverly.hills.money.gang.state.entity; public enum RPGPlayerClass { - - COMMONER, BERSERK, TANK, WARRIOR; + WARRIOR, ANGRY_SKELETON, DEMON_TANK; } diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/AbstractGameServerTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/AbstractGameServerTest.java index b7012831..acea07d3 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/AbstractGameServerTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/AbstractGameServerTest.java @@ -12,6 +12,7 @@ import com.beverly.hills.money.gang.network.GameConnection; import com.beverly.hills.money.gang.network.SecondaryGameConnection; import com.beverly.hills.money.gang.proto.GetServerInfoCommand; +import com.beverly.hills.money.gang.proto.PlayerClass; import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.proto.ServerResponse.GameEvent; import com.beverly.hills.money.gang.queue.QueueReader; @@ -115,7 +116,8 @@ private void waitUntilServerIsHealthy() throws IOException, InterruptedException for (int i = 0; i < maxHealthChecks; i++) { gameConnection = new GameConnection(HostPort.builder().host("localhost").port(port).build()); gameConnection.waitUntilConnected(5_000); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); + gameConnection.write(GetServerInfoCommand.newBuilder() + .setPlayerClass(PlayerClass.WARRIOR).build()); try { waitUntilGetResponses(gameConnection.getResponse(), 1, 2_000); LOG.info("Server is ready on port {}", port); @@ -130,7 +132,7 @@ private void waitUntilServerIsHealthy() throws IOException, InterruptedException } @AfterEach - public void tearDown() { + public void tearDown() throws InterruptedException { gameConnections.forEach(AbstractGameConnection::disconnect); gameConnections.forEach(gameConnection -> { gameConnection.getErrors().list().forEach( diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/AllPowerUpTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/AllPowerUpTest.java index 5a77dbc2..b7131d59 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/AllPowerUpTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/AllPowerUpTest.java @@ -39,6 +39,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_DEFENCE_SPAWN_MLS", value = "5000") @SetEnvironmentVariable(key = "GAME_SERVER_DEFENCE_LASTS_FOR_MLS", value = "2000") @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "999999") + @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "999999") public class AllPowerUpTest extends AbstractGameServerTest { @@ -71,7 +72,7 @@ public void testPickUpPowerUpAll() playerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(playerConnection.getResponse(), 2); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/BannedPlayersRegistryTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/BannedPlayersRegistryTest.java index 10ce08af..a1c44dab 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/BannedPlayersRegistryTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/BannedPlayersRegistryTest.java @@ -16,6 +16,7 @@ @ExtendWith({SpringExtension.class, OutputCaptureExtension.class}) @ContextConfiguration(classes = TestConfig.class) @SetEnvironmentVariable(key = "GAME_SERVER_BAN_TIMEOUT_MLS", value = "5000") + public class BannedPlayersRegistryTest { @Autowired diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/ChatEventTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/ChatEventTest.java index bfdc7504..ed28cec1 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/ChatEventTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/ChatEventTest.java @@ -24,6 +24,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_POWER_UPS_ENABLED", value = "false") @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") @SetEnvironmentVariable(key = "GAME_SERVER_MAX_IDLE_TIME_MLS", value = "99999") +@SetEnvironmentVariable(key = "GAME_SERVER_MAX_PLAYERS_PER_GAME", value = "5") @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MAX_PLAYERS_PER_GAME", value = "5") @@ -43,7 +44,7 @@ public void testChatManyPlayers() throws IOException, InterruptedException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name " + i) .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(gameConnection.getResponse(), 1); @@ -103,7 +104,7 @@ public void testChatManyPlayersConcurrent() throws IOException, InterruptedExcep gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name " + i) .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(gameConnection.getResponse(), 1); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/ConcurrentKillTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/ConcurrentKillTest.java index ca685a4b..57443318 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/ConcurrentKillTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/ConcurrentKillTest.java @@ -41,7 +41,7 @@ public class ConcurrentKillTest extends AbstractGameServerTest { * @then none of them receive an ERROR event */ @RepeatedTest(4) - public void testKillConcurrent() throws InterruptedException, IOException { + public void testKillConcurrent() throws InterruptedException { AtomicBoolean failed = new AtomicBoolean(false); List joinThreads = new ArrayList<>(); List spawnsWithConnections = new CopyOnWriteArrayList<>(); @@ -54,7 +54,7 @@ public void testKillConcurrent() throws InterruptedException, IOException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name " + finalJ) .setGameId(0).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/DefencePowerUpTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/DefencePowerUpTest.java index 1d494eb1..26b8f3e3 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/DefencePowerUpTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/DefencePowerUpTest.java @@ -11,17 +11,16 @@ import com.beverly.hills.money.gang.powerup.DefencePowerUp; import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.PushGameEventCommand; import com.beverly.hills.money.gang.proto.PushGameEventCommand.GameEventType; import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.proto.ServerResponse.GamePowerUpType; import com.beverly.hills.money.gang.proto.ServerResponse.PowerUpSpawnEventItem; -import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.Vector; import java.io.IOException; import java.util.Arrays; import java.util.stream.Collectors; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; import org.springframework.boot.test.mock.mockito.SpyBean; @@ -32,6 +31,7 @@ @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") + public class DefencePowerUpTest extends AbstractGameServerTest { @SpyBean @@ -52,7 +52,7 @@ public void testPickUpPowerUpDefence() playerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(playerConnection.getResponse(), 2); @@ -124,7 +124,7 @@ public void testPickUpPowerUpDefence() port); observerAfterRevert.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("after revert") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerAfterRevert.getResponse()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/GameConnectionTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/GameConnectionTest.java index 151da66b..1594504a 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/GameConnectionTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/GameConnectionTest.java @@ -10,12 +10,11 @@ import com.beverly.hills.money.gang.proto.GetServerInfoCommand; import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.PlayerClass; -import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.proto.PlayerSkinColor; +import com.beverly.hills.money.gang.proto.ServerResponse; import java.io.IOException; import java.net.ConnectException; import java.net.UnknownHostException; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; @@ -23,6 +22,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") + public class GameConnectionTest extends AbstractGameServerTest { /** @@ -37,7 +37,7 @@ public void testExit() throws IOException, InterruptedException { gameConnection1.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection1.getResponse()); @@ -48,7 +48,7 @@ public void testExit() throws IOException, InterruptedException { GameConnection gameConnection2 = createGameConnection( "localhost", port); gameConnection2.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my other player name") .setGameId(gameToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection2.getResponse()); @@ -60,7 +60,8 @@ public void testExit() throws IOException, InterruptedException { assertTrue(gameConnection1.isDisconnected(), "Player 1 should be disconnected now"); assertTrue(gameConnection2.isConnected(), "Player 2 should be connected"); - gameConnection1.write(GetServerInfoCommand.newBuilder().build()); + gameConnection1.write(GetServerInfoCommand.newBuilder() + .setPlayerClass(PlayerClass.WARRIOR).build()); Thread.sleep(250); assertEquals(0, gameConnection1.getResponse().size(), "Should be no response because the connection is closed"); @@ -96,7 +97,8 @@ public void testDisconnectTwice() throws IOException, InterruptedException { gameConnection.disconnect(); // call twice assertTrue(gameConnection.isDisconnected(), "Should be disconnected after disconnecting"); assertFalse(gameConnection.isConnected()); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); + gameConnection.write(GetServerInfoCommand.newBuilder() + .setPlayerClass(PlayerClass.WARRIOR).build()); Thread.sleep(250); assertEquals(0, gameConnection.getResponse().size(), "Should be no response because the connection is closed"); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/GameOverTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/GameOverTest.java index aeb55153..ac1dfd67 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/GameOverTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/GameOverTest.java @@ -22,6 +22,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_MAX_IDLE_TIME_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_FRAGS_PER_GAME", value = "5") @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") + @SetEnvironmentVariable(key = "GAME_SERVER_DEFAULT_SHOTGUN_DAMAGE", value = "100") // one shot kill public class GameOverTest extends AbstractGameServerTest { @@ -41,7 +42,7 @@ public void testGameOver() throws Exception { killerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName(shooterPlayerName) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); @@ -54,7 +55,7 @@ public void testGameOver() throws Exception { port); deadConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my other player name " + i) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/GameServerInfoTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/GameServerInfoTest.java index 2f91e00b..f1b6fde7 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/GameServerInfoTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/GameServerInfoTest.java @@ -6,6 +6,7 @@ import com.beverly.hills.money.gang.config.ServerConfig; import com.beverly.hills.money.gang.network.GameConnection; import com.beverly.hills.money.gang.proto.GetServerInfoCommand; +import com.beverly.hills.money.gang.proto.PlayerClass; import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.state.AttackType; import java.io.IOException; @@ -19,18 +20,20 @@ @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") + public class GameServerInfoTest extends AbstractGameServerTest { /** - * @given a running game serve + * @given a running game server * @when player 1 requests server info * @then player 1 gets server info for all games */ @Test - public void testGetServerInfo() throws IOException { + public void testGetServerInfoCommoner() throws IOException { GameConnection gameConnection = createGameConnection("localhost", port); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); + gameConnection.write(GetServerInfoCommand.newBuilder() + .setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); assertEquals(0, gameConnection.getErrors().size(), "Should be no error"); assertEquals(1, gameConnection.getResponse().size(), "Should be exactly one response"); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/IdleClientTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/IdleClientTest.java index 44b94752..383485bd 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/IdleClientTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/IdleClientTest.java @@ -45,14 +45,16 @@ public void testIdleClientDisconnect() throws IOException, InterruptedException gameConnectionIdle.write( JoinGameCommand.newBuilder() .setVersion(ClientConfig.VERSION) - .setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) - .setPlayerName("my player name") + .setSkin(PlayerSkinColor.GREEN) + .setPlayerClass(PlayerClass.WARRIOR) + .setPlayerName("some player name") .setGameId(gameToConnectTo).build()); gameConnectionObserver.write( JoinGameCommand.newBuilder() .setVersion(ClientConfig.VERSION) - .setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) - .setPlayerName("my player name observer") + .setSkin(PlayerSkinColor.GREEN) + .setPlayerClass(PlayerClass.WARRIOR) + .setPlayerName("other player name observer") .setGameId(gameToConnectTo).build()); waitUntilQueueNonEmpty(gameConnectionIdle.getResponse()); waitUntilQueueNonEmpty(gameConnectionObserver.getResponse()); @@ -69,7 +71,7 @@ public void testIdleClientDisconnect() throws IOException, InterruptedException emptyQueue(gameConnectionObserver.getResponse()); emptyQueue(gameConnectionIdle.getResponse()); - gameConnectionIdle.write(GetServerInfoCommand.newBuilder().build()); + gameConnectionIdle.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(gameConnectionIdle.getResponse()); ServerResponse gameServerInfoResponse = gameConnectionIdle.getResponse().poll().get(); var myGame = gameServerInfoResponse.getServerInfo().getGamesList().stream().filter(gameInfo @@ -102,7 +104,8 @@ public void testIdleClientDisconnect() throws IOException, InterruptedException GameConnection newGameConnection = createGameConnection("localhost", port); - newGameConnection.write(GetServerInfoCommand.newBuilder().build()); + newGameConnection.write(GetServerInfoCommand.newBuilder() + .setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(newGameConnection.getResponse()); ServerResponse serverResponseAfterIdle = newGameConnection.getResponse().poll().get(); var myGameAfterIdle = serverResponseAfterIdle.getServerInfo().getGamesList().stream() @@ -115,7 +118,7 @@ public void testIdleClientDisconnect() throws IOException, InterruptedException "Idle player should be disconnected because it was idle for too long. Only observer player is online"); emptyQueue(gameConnectionIdle.getWarning()); - gameConnectionIdle.write(GetServerInfoCommand.newBuilder().build()); + gameConnectionIdle.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); Thread.sleep(250); assertEquals(1, gameConnectionIdle.getWarning().size(), "Should be one warning as we can't write using disconnected connection"); @@ -159,7 +162,7 @@ public void testIdleDeadClient() throws IOException, InterruptedException { puncherConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName(puncherPlayerName) .setGameId(gameIdToConnectTo).build()); @@ -167,7 +170,7 @@ public void testIdleDeadClient() throws IOException, InterruptedException { deadConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(puncherConnection.getResponse()); @@ -269,7 +272,7 @@ public void testNotIdleClientMoving() throws IOException, InterruptedException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ClientConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -278,7 +281,7 @@ public void testNotIdleClientMoving() throws IOException, InterruptedException { GameConnection observerConnection = createGameConnection("localhost", port); - observerConnection.write(GetServerInfoCommand.newBuilder().build()); + observerConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(observerConnection.getResponse()); ServerResponse serverResponse = observerConnection.getResponse().poll().get(); var myGame = serverResponse.getServerInfo().getGamesList().stream().filter(gameInfo @@ -309,7 +312,7 @@ public void testNotIdleClientMoving() throws IOException, InterruptedException { GameConnection newGameConnection = createGameConnection("localhost", port); - newGameConnection.write(GetServerInfoCommand.newBuilder().build()); + newGameConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(newGameConnection.getResponse()); ServerResponse serverResponseAfterMoving = newGameConnection.getResponse().poll().get(); var myGameAfterMoving = serverResponseAfterMoving.getServerInfo().getGamesList().stream() @@ -335,7 +338,7 @@ public void testMoveThenIdleClient() throws IOException, InterruptedException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ClientConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -363,7 +366,7 @@ public void testMoveThenIdleClient() throws IOException, InterruptedException { assertTrue(gameConnection.isDisconnected()); GameConnection newGameConnection = createGameConnection("localhost", port); - newGameConnection.write(GetServerInfoCommand.newBuilder().build()); + newGameConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(newGameConnection.getResponse()); ServerResponse serverResponseAfterMoving = newGameConnection.getResponse().poll().get(); var myGameAfterMoving = serverResponseAfterMoving.getServerInfo().getGamesList().stream() diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/IdleServerTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/IdleServerTest.java index 5c067ec3..4a3e2c6c 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/IdleServerTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/IdleServerTest.java @@ -8,12 +8,11 @@ import com.beverly.hills.money.gang.proto.GetServerInfoCommand; import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.PushGameEventCommand; import com.beverly.hills.money.gang.proto.ServerResponse; -import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.Vector; import java.io.IOException; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; @@ -22,6 +21,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_MAX_IDLE_TIME_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "99999") @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "1000") + public class IdleServerTest extends AbstractGameServerTest { /** @@ -37,14 +37,15 @@ public void testClientIsMovingButServerIsIdle() throws IOException, InterruptedE gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); var mySpawn = gameConnection.getResponse().poll().get().getGameEvents().getEvents(0); int playerId = mySpawn.getPlayer().getPlayerId(); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); + gameConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR) + .build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); ServerResponse serverResponse = gameConnection.getResponse().poll().get(); var myGame = serverResponse.getServerInfo().getGamesList().stream().filter(gameInfo diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/InvisibilityPowerUpTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/InvisibilityPowerUpTest.java index 4452cdc2..f72ad7f7 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/InvisibilityPowerUpTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/InvisibilityPowerUpTest.java @@ -11,17 +11,16 @@ import com.beverly.hills.money.gang.powerup.InvisibilityPowerUp; import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.PushGameEventCommand; import com.beverly.hills.money.gang.proto.PushGameEventCommand.GameEventType; import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.proto.ServerResponse.GamePowerUpType; import com.beverly.hills.money.gang.proto.ServerResponse.PowerUpSpawnEventItem; -import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.Vector; import java.io.IOException; import java.util.Arrays; import java.util.stream.Collectors; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; import org.springframework.boot.test.mock.mockito.SpyBean; @@ -32,6 +31,7 @@ @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") + public class InvisibilityPowerUpTest extends AbstractGameServerTest { @@ -52,7 +52,7 @@ public void testPickUpPowerUpInvisibility() port); playerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(playerConnection.getResponse(), 2); @@ -126,7 +126,7 @@ public void testPickUpPowerUpInvisibility() observerAfterRevert.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("after revert") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerAfterRevert.getResponse()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/JoinGameTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/JoinGameTest.java index df41555e..380dcc4b 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/JoinGameTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/JoinGameTest.java @@ -51,7 +51,7 @@ public class JoinGameTest extends AbstractGameServerTest { * @then the player is connected */ @ParameterizedTest - @ValueSource(ints = {0, 1, 2, 3}) + @ValueSource(ints = {0, 1, 2}) public void testJoinGame(int playerClassNumber) throws Exception { int gameIdToConnectTo = 0; @@ -74,7 +74,8 @@ public void testJoinGame(int playerClassNumber) throws Exception { assertEquals("my player name", mySpawnGameEvent.getPlayer().getPlayerName()); assertEquals(100, mySpawnGameEvent.getPlayer().getHealth()); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); + gameConnection.write( + GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); assertEquals(0, gameConnection.getErrors().size(), "Should be no error"); assertEquals(1, gameConnection.getResponse().size(), "Should be exactly one response"); @@ -98,7 +99,7 @@ public void testJoinGame(int playerClassNumber) throws Exception { newGameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.DRACULA_BERSERK) + .setPlayerClass(PlayerClass.ANGRY_SKELETON) .setPlayerName("new player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(newGameConnection.getResponse()); @@ -114,7 +115,7 @@ public void testJoinGame(int playerClassNumber) throws Exception { assertEquals(1, newJoinedPlayerResponse.getGameEvents().getEventsList().size()); var newPlayerSpawn = newJoinedPlayerResponse.getGameEvents().getEventsList().get(0); assertEquals(newPlayerId, newPlayerSpawn.getPlayer().getPlayerId()); - assertEquals(PlayerClass.DRACULA_BERSERK, newPlayerSpawn.getPlayer().getPlayerClass()); + assertEquals(PlayerClass.ANGRY_SKELETON, newPlayerSpawn.getPlayer().getPlayerClass()); assertEquals(GameEventType.JOIN, newPlayerSpawn.getEventType()); } @@ -133,7 +134,7 @@ public void testJoinGameAfterManyPlayersJoined() throws Exception { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.ORANGE) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("player name " + i) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -144,7 +145,7 @@ public void testJoinGameAfterManyPlayersJoined() throws Exception { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -188,7 +189,8 @@ public void testJoinGameBannedPlayer() throws IOException { // need a new game connection because the previous is closed var newGameConnection = createGameConnection("localhost", port); - newGameConnection.write(GetServerInfoCommand.newBuilder().build()); + newGameConnection.write( + GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(newGameConnection.getResponse()); assertEquals(0, newGameConnection.getErrors().size(), "Should be no error"); assertEquals(1, newGameConnection.getResponse().size(), "Should be exactly one response"); @@ -215,7 +217,7 @@ public void testJoinGameNotExistingGame() throws IOException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -230,7 +232,8 @@ public void testJoinGameNotExistingGame() throws IOException { // need a new game connection because the previous is closed var newGameConnection = createGameConnection("localhost", port); - newGameConnection.write(GetServerInfoCommand.newBuilder().build()); + newGameConnection.write( + GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(newGameConnection.getResponse()); assertEquals(0, newGameConnection.getErrors().size(), "Should be no error"); assertEquals(1, newGameConnection.getResponse().size(), "Should be exactly one response"); @@ -257,7 +260,7 @@ public void testJoinGameWrongVersion() throws IOException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion("0.1.1-SNAPSHOT") - .setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -271,7 +274,8 @@ public void testJoinGameWrongVersion() throws IOException { // need a new game connection because the previous is closed var newGameConnection = createGameConnection("localhost", port); - newGameConnection.write(GetServerInfoCommand.newBuilder().build()); + newGameConnection.write( + GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(newGameConnection.getResponse()); assertEquals(0, newGameConnection.getErrors().size(), "Should be no error"); assertEquals(1, newGameConnection.getResponse().size(), "Should be exactly one response"); @@ -299,7 +303,7 @@ public void testJoinGameTooMany() throws IOException, InterruptedException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name " + i) .setGameId(0).build()); } @@ -309,7 +313,7 @@ public void testJoinGameTooMany() throws IOException, InterruptedException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(0).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -337,7 +341,7 @@ public void testJoinSameName() throws IOException, InterruptedException { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("same name") .setGameId(0).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -347,7 +351,7 @@ public void testJoinSameName() throws IOException, InterruptedException { sameNameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("same name") .setGameId(0).build()); waitUntilQueueNonEmpty(sameNameConnection.getResponse()); @@ -387,7 +391,7 @@ public void testJoinGameAlmostFull() throws Exception { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name " + finalI) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -423,7 +427,7 @@ public void testJoinGameAlmostFull() throws Exception { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); @@ -462,7 +466,8 @@ public void testJoinGameAlmostFull() throws Exception { assertEquals(connectedPlayersPositions.keySet(), spawnedPlayersIds, "All spawned players should be returned in the response"); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); + gameConnection.write( + GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); assertEquals(0, gameConnection.getErrors().size(), "Should be no error"); assertEquals(1, gameConnection.getResponse().size(), "Should be exactly one response"); @@ -484,64 +489,4 @@ public void testJoinGameAlmostFull() throws Exception { } } } - - /** - * @given a running game server - * @when max number of player connect to all games - * @then all players are successfully connected - */ - @Test - @Disabled("Circle CI fails to run it for some reason") - public void testJoinGameMaxPlayersAllGames() throws Exception { - List threads = new ArrayList<>(); - for (int gameId = 0; gameId < ServerConfig.GAMES_TO_CREATE; gameId++) { - for (int j = 0; j < ServerConfig.MAX_PLAYERS_PER_GAME; j++) { - int finalGameId = gameId; - int finalJ = j; - threads.add(new Thread(() -> { - try { - GameConnection gameConnection = createGameConnection("localhost", - port); - gameConnection.write( - JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER) - .setPlayerName("my player name " + finalJ) - .setGameId(finalGameId).build()); - waitUntilQueueNonEmpty(gameConnection.getResponse()); - Thread.sleep(500); - } catch (Exception e) { - LOG.error("Error while running test", e); - } - })); - } - } - - threads.forEach(Thread::start); - threads.forEach(thread -> { - try { - thread.join(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - }); - assertEquals(ServerConfig.GAMES_TO_CREATE * ServerConfig.MAX_PLAYERS_PER_GAME, - gameConnections.size()); - gameConnections.forEach(gameConnection -> assertTrue(gameConnection.isConnected())); - - GameConnection gameConnection = createGameConnection("localhost", port); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); - waitUntilQueueNonEmpty(gameConnection.getResponse()); - assertEquals(0, gameConnection.getErrors().size(), "Should be no error"); - assertEquals(1, gameConnection.getResponse().size(), "Should be exactly one response"); - ServerResponse serverResponse = gameConnection.getResponse().poll().get(); - assertTrue(serverResponse.hasServerInfo(), "Must include server info only"); - List games = serverResponse.getServerInfo().getGamesList(); - assertEquals(ServerConfig.GAMES_TO_CREATE, games.size()); - for (ServerResponse.GameInfo gameInfo : games) { - assertEquals(ServerConfig.MAX_PLAYERS_PER_GAME, gameInfo.getMaxGamePlayers()); - assertEquals(ServerConfig.MAX_PLAYERS_PER_GAME, gameInfo.getPlayersOnline(), - "All players are connected"); - } - } } diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/LoadBalancedGameConnectionTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/LoadBalancedGameConnectionTest.java index dc3d486f..048a5d9c 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/LoadBalancedGameConnectionTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/LoadBalancedGameConnectionTest.java @@ -11,13 +11,12 @@ import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.MergeConnectionCommand; import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.PushGameEventCommand; import com.beverly.hills.money.gang.proto.ServerResponse; -import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.Vector; import com.beverly.hills.money.gang.stats.NetworkStatsReader; import java.util.List; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; @@ -26,6 +25,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_MAX_IDLE_TIME_MLS", value = "99999") @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "250") + @SetEnvironmentVariable(key = "GAME_SERVER_PLAYER_SPEED_CHECK_FREQUENCY_MLS", value = "1000") public class LoadBalancedGameConnectionTest extends AbstractGameServerTest { @@ -42,7 +42,7 @@ public void testLoadBalancedGameConnection() throws Exception { port); movingPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(movingPlayerConnection.getResponse()); @@ -56,7 +56,7 @@ public void testLoadBalancedGameConnection() throws Exception { observerPlayerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("new player") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(observerPlayerConnection.getResponse(), 2); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/MergeConnectionTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/MergeConnectionTest.java index 43e88987..b884abce 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/MergeConnectionTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/MergeConnectionTest.java @@ -10,11 +10,10 @@ import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.MergeConnectionCommand; import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.proto.ServerResponse.GameEvent; -import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.registry.GameRoomRegistry; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +23,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_MAX_IDLE_TIME_MLS", value = "99999") @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "99999") + public class MergeConnectionTest extends AbstractGameServerTest { @Autowired @@ -41,7 +41,7 @@ public void testMergeConnection() throws Exception { gameConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/MoveAntiCheatTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/MoveAntiCheatTest.java index 2dc0f65d..5ce7e48d 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/MoveAntiCheatTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/MoveAntiCheatTest.java @@ -23,6 +23,7 @@ @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "9999") @SetEnvironmentVariable(key = "GAME_SERVER_PLAYER_SPEED_CHECK_FREQUENCY_MLS", value = "1000") + public class MoveAntiCheatTest extends AbstractGameServerTest { @MockBean @@ -41,7 +42,7 @@ public void testMoveTooFast() throws Exception { cheatingPlayerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(cheatingPlayerConnection.getResponse()); @@ -53,7 +54,7 @@ public void testMoveTooFast() throws Exception { "localhost", port); observerPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("new player") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerPlayerConnection.getResponse()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/MoveEventTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/MoveEventTest.java index 20eafbb9..1cab33af 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/MoveEventTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/MoveEventTest.java @@ -24,6 +24,7 @@ @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "250") @SetEnvironmentVariable(key = "GAME_SERVER_PLAYER_SPEED_CHECK_FREQUENCY_MLS", value = "1000") + public class MoveEventTest extends AbstractGameServerTest { /** @@ -38,7 +39,7 @@ public void testMove() throws Exception { port); movingPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(movingPlayerConnection.getResponse()); @@ -50,7 +51,7 @@ public void testMove() throws Exception { "localhost", port); observerPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("new player") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerPlayerConnection.getResponse()); @@ -125,7 +126,7 @@ public void testMoveAscendingSequence() throws Exception { port); movingPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(movingPlayerConnection.getResponse()); @@ -137,7 +138,7 @@ public void testMoveAscendingSequence() throws Exception { "localhost", port); observerPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("new player") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerPlayerConnection.getResponse()); @@ -195,7 +196,7 @@ public void testMoveOutOfOrderSequence() throws Exception { port); movingPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(movingPlayerConnection.getResponse()); @@ -207,7 +208,7 @@ public void testMoveOutOfOrderSequence() throws Exception { "localhost", port); observerPlayerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("new player") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerPlayerConnection.getResponse()); @@ -279,7 +280,7 @@ public void testMoveWrongPlayerId() throws Exception { port); observerConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerConnection.getResponse()); @@ -291,7 +292,7 @@ public void testMoveWrongPlayerId() throws Exception { port); wrongGameConnection.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("new player") .setGameId(gameIdToConnectTo).build()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/PingTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/PingTest.java index 873bc8f3..a2118379 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/PingTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/PingTest.java @@ -3,12 +3,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.beverly.hills.money.gang.config.ServerConfig; import com.beverly.hills.money.gang.network.GameConnection; import com.beverly.hills.money.gang.network.SecondaryGameConnection; import java.io.IOException; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/QuadDamagePowerUpTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/QuadDamagePowerUpTest.java index cd7937ce..f9a1f207 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/QuadDamagePowerUpTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/QuadDamagePowerUpTest.java @@ -11,17 +11,16 @@ import com.beverly.hills.money.gang.powerup.QuadDamagePowerUp; import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.PushGameEventCommand; import com.beverly.hills.money.gang.proto.PushGameEventCommand.GameEventType; import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.proto.ServerResponse.GamePowerUpType; import com.beverly.hills.money.gang.proto.ServerResponse.PowerUpSpawnEventItem; -import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.Vector; import java.io.IOException; import java.util.Arrays; import java.util.stream.Collectors; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.SetEnvironmentVariable; import org.springframework.boot.test.mock.mockito.SpyBean; @@ -32,6 +31,7 @@ @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_TELEPORTS_ENABLED", value = "false") + public class QuadDamagePowerUpTest extends AbstractGameServerTest { @SpyBean @@ -52,7 +52,7 @@ public void testPickUpPowerUpQuadDamage() playerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(playerConnection.getResponse(), 2); @@ -123,7 +123,7 @@ public void testPickUpPowerUpQuadDamage() port); observerAfterRevert.write( JoinGameCommand.newBuilder() - .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.COMMONER) + .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("after revert") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerAfterRevert.getResponse()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/RespawnEventTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/RespawnEventTest.java index 0f9e9e21..a23a6c32 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/RespawnEventTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/RespawnEventTest.java @@ -23,6 +23,7 @@ @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "99999") @SetEnvironmentVariable(key = "GAME_SERVER_MAX_IDLE_TIME_MLS", value = "99999") @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "99999") + public class RespawnEventTest extends AbstractGameServerTest { /** @@ -39,7 +40,7 @@ public void testRespawn() throws Exception { killerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.PINK) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName(shooterPlayerName) .setGameId(gameIdToConnectTo).build()); @@ -47,7 +48,7 @@ public void testRespawn() throws Exception { deadConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.PURPLE) - .setPlayerClass(PlayerClass.COMMONER) + .setPlayerClass(PlayerClass.WARRIOR) .setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/ServerRunnerTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/ServerRunnerTest.java index 84cb41a1..3bebd0c4 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/ServerRunnerTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/ServerRunnerTest.java @@ -12,7 +12,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/ShootingEventTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/ShootingEventTest.java index 27df9d6c..73148133 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/ShootingEventTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/ShootingEventTest.java @@ -1,6 +1,5 @@ package com.beverly.hills.money.gang.it; -import static com.beverly.hills.money.gang.state.entity.AttackStats.ATTACKS_INFO; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -23,7 +22,9 @@ import com.beverly.hills.money.gang.proto.WeaponType; import com.beverly.hills.money.gang.spawner.Spawner; import com.beverly.hills.money.gang.state.AttackType; +import com.beverly.hills.money.gang.state.entity.AttackStats; import com.beverly.hills.money.gang.state.entity.PlayerState; +import com.beverly.hills.money.gang.state.entity.RPGPlayerClass; import java.io.IOException; import java.util.List; import java.util.function.Supplier; @@ -53,12 +54,12 @@ public void testShootMiss() throws IOException { GameConnection shooterConnection = createGameConnection("localhost", port); shooterConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection observerConnection = createGameConnection("localhost", port); observerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); waitUntilQueueNonEmpty(observerConnection.getResponse()); @@ -116,12 +117,12 @@ public void testPunchMiss() throws IOException { GameConnection puncherConnection = createGameConnection("localhost", port); puncherConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection observerConnection = createGameConnection("localhost", port); observerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(puncherConnection.getResponse(), 2); waitUntilGetResponses(observerConnection.getResponse(), 2); @@ -178,7 +179,7 @@ public void testPunchMiss() throws IOException { @Test public void testShootHit() throws Exception { - var shotgunInfo = ATTACKS_INFO.stream() + var shotgunInfo = AttackStats.getAttacksInfo(RPGPlayerClass.WARRIOR).stream() .filter(attackInfo -> attackInfo.getAttackType() == AttackType.SHOTGUN).findFirst().get(); doReturn(PlayerState.PlayerCoordinates.builder() @@ -195,12 +196,12 @@ public void testShootHit() throws Exception { GameConnection shooterConnection = createGameConnection("localhost", port); shooterConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection getShotConnection = createGameConnection("localhost", port); getShotConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); ServerResponse shooterPlayerSpawn = shooterConnection.getResponse().poll().get(); @@ -259,7 +260,7 @@ public void testShootHit() throws Exception { assertEquals(2, shooterConnection.getNetworkStats().getSentMessages(), "Only 2 messages must be sent by shooter: join + shoot"); emptyQueue(shooterConnection.getResponse()); - shooterConnection.write(GetServerInfoCommand.newBuilder().build()); + shooterConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); var serverInfoResponse = shooterConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -293,12 +294,12 @@ public void testShootHitVeryClose() throws Exception { GameConnection shooterConnection = createGameConnection("localhost", port); shooterConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection getShotConnection = createGameConnection("localhost", port); getShotConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); ServerResponse shooterPlayerSpawn = shooterConnection.getResponse().poll().get(); @@ -358,7 +359,7 @@ public void testShootHitVeryClose() throws Exception { assertEquals(2, shooterConnection.getNetworkStats().getSentMessages(), "Only 2 messages must be sent by shooter: join + shoot"); emptyQueue(shooterConnection.getResponse()); - shooterConnection.write(GetServerInfoCommand.newBuilder().build()); + shooterConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); var serverInfoResponse = shooterConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -393,12 +394,12 @@ public void testShootHitClose() throws Exception { GameConnection shooterConnection = createGameConnection("localhost", port); shooterConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection getShotConnection = createGameConnection("localhost", port); getShotConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); ServerResponse shooterPlayerSpawn = shooterConnection.getResponse().poll().get(); @@ -458,7 +459,7 @@ public void testShootHitClose() throws Exception { assertEquals(2, shooterConnection.getNetworkStats().getSentMessages(), "Only 2 messages must be sent by shooter: join + shoot"); emptyQueue(shooterConnection.getResponse()); - shooterConnection.write(GetServerInfoCommand.newBuilder().build()); + shooterConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); var serverInfoResponse = shooterConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -481,12 +482,12 @@ public void testPunchHit() throws Exception { GameConnection punchingConnection = createGameConnection("localhost", port); punchingConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection getPunchedConnection = createGameConnection("localhost", port); getPunchedConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(punchingConnection.getResponse()); ServerResponse puncherPlayerSpawn = punchingConnection.getResponse().poll().get(); @@ -545,7 +546,7 @@ public void testPunchHit() throws Exception { assertEquals(2, punchingConnection.getNetworkStats().getSentMessages(), "Only 2 messages must be sent by puncher: join + punch"); emptyQueue(punchingConnection.getResponse()); - punchingConnection.write(GetServerInfoCommand.newBuilder().build()); + punchingConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(punchingConnection.getResponse()); var serverInfoResponse = punchingConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -567,12 +568,12 @@ public void testShootHitTooFar() throws Exception { GameConnection shooterConnection = createGameConnection("localhost", port); shooterConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection getShotConnection = createGameConnection("localhost", port); getShotConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); @@ -615,12 +616,12 @@ public void testShootPunchTooFar() throws Exception { GameConnection puncherConnection = createGameConnection("localhost", port); puncherConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection getPunchedConnection = createGameConnection("localhost", port); getPunchedConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(puncherConnection.getResponse()); @@ -661,7 +662,7 @@ public void testShootPunchTooFar() throws Exception { public void testShootKill() throws Exception { int gameIdToConnectTo = 0; String shooterPlayerName = "killer"; - var shotgunInfo = ATTACKS_INFO.stream() + var shotgunInfo = AttackStats.getAttacksInfo(RPGPlayerClass.WARRIOR).stream() .filter(attackInfo -> attackInfo.getAttackType() == AttackType.SHOTGUN).findFirst().get(); doReturn(PlayerState.PlayerCoordinates.builder() .position(com.beverly.hills.money.gang.state.entity.Vector.builder().x(0F).y(0F).build()) @@ -675,13 +676,13 @@ public void testShootKill() throws Exception { GameConnection killerConnection = createGameConnection("localhost", port); killerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(shooterPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(shooterPlayerName) .setGameId(gameIdToConnectTo).build()); GameConnection deadConnection = createGameConnection("localhost", port); deadConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); ServerResponse shooterPlayerSpawn = killerConnection.getResponse().poll().get(); @@ -757,7 +758,7 @@ public void testShootKill() throws Exception { assertEquals(WeaponType.SHOTGUN, killerShootingEvent.getWeaponType()); assertEquals(shooterPlayerId, killerShootingEvent.getPlayer().getPlayerId()); - killerConnection.write(GetServerInfoCommand.newBuilder().build()); + killerConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); var serverInfoResponse = killerConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -771,7 +772,7 @@ public void testShootKill() throws Exception { GameConnection observerConnection = createGameConnection("localhost", port); observerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(observerPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(observerPlayerName) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerConnection.getResponse()); @@ -815,7 +816,7 @@ public void testShootKill() throws Exception { public void testShootMinigunKill() throws Exception { int gameIdToConnectTo = 0; String shooterPlayerName = "killer"; - var shotgunInfo = ATTACKS_INFO.stream() + var shotgunInfo = AttackStats.getAttacksInfo(RPGPlayerClass.WARRIOR).stream() .filter(attackInfo -> attackInfo.getAttackType() == AttackType.MINIGUN).findFirst().get(); doReturn(PlayerState.PlayerCoordinates.builder() .position(com.beverly.hills.money.gang.state.entity.Vector.builder().x(0F).y(0F).build()) @@ -829,13 +830,13 @@ public void testShootMinigunKill() throws Exception { GameConnection killerConnection = createGameConnection("localhost", port); killerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(shooterPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(shooterPlayerName) .setGameId(gameIdToConnectTo).build()); GameConnection deadConnection = createGameConnection("localhost", port); deadConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); ServerResponse shooterPlayerSpawn = killerConnection.getResponse().poll().get(); @@ -911,7 +912,7 @@ public void testShootMinigunKill() throws Exception { assertEquals(WeaponType.MINIGUN, killerShootingEvent.getWeaponType()); assertEquals(shooterPlayerId, killerShootingEvent.getPlayer().getPlayerId()); - killerConnection.write(GetServerInfoCommand.newBuilder().build()); + killerConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); var serverInfoResponse = killerConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -925,7 +926,7 @@ public void testShootMinigunKill() throws Exception { GameConnection observerConnection = createGameConnection("localhost", port); observerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(observerPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(observerPlayerName) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerConnection.getResponse()); @@ -972,13 +973,13 @@ public void testRailgunKillRecovery() throws Exception { GameConnection killerConnection = createGameConnection("localhost", port); killerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(shooterPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(shooterPlayerName) .setGameId(gameIdToConnectTo).build()); GameConnection deadConnection = createGameConnection("localhost", port); deadConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); ServerResponse shooterPlayerSpawn = killerConnection.getResponse().poll().get(); @@ -1030,7 +1031,7 @@ public void testRailgunKillRecovery() throws Exception { assertEquals(WeaponType.RAILGUN, killerShootingEvent.getWeaponType()); assertEquals(shooterPlayerId, killerShootingEvent.getPlayer().getPlayerId()); - killerConnection.write(GetServerInfoCommand.newBuilder().build()); + killerConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); var serverInfoResponse = killerConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -1047,7 +1048,7 @@ public void testRailgunKillRecovery() throws Exception { killerConnection = createGameConnection("localhost", port); killerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setRecoveryPlayerId(shooterPlayerId) + .setPlayerClass(PlayerClass.WARRIOR).setRecoveryPlayerId(shooterPlayerId) .setPlayerName(shooterPlayerName).setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(killerConnection.getResponse(), 2); var newShooterPlayerSpawn = killerConnection.getResponse().poll().get(); @@ -1060,7 +1061,7 @@ public void testRailgunKillRecovery() throws Exception { GameConnection observerConnection = createGameConnection("localhost", port); observerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(observerPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(observerPlayerName) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerConnection.getResponse()); @@ -1107,13 +1108,13 @@ public void testRailgunKill() throws Exception { GameConnection killerConnection = createGameConnection("localhost", port); killerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(shooterPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(shooterPlayerName) .setGameId(gameIdToConnectTo).build()); GameConnection deadConnection = createGameConnection("localhost", port); deadConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); ServerResponse shooterPlayerSpawn = killerConnection.getResponse().poll().get(); @@ -1165,7 +1166,7 @@ public void testRailgunKill() throws Exception { assertEquals(WeaponType.RAILGUN, killerShootingEvent.getWeaponType()); assertEquals(shooterPlayerId, killerShootingEvent.getPlayer().getPlayerId()); - killerConnection.write(GetServerInfoCommand.newBuilder().build()); + killerConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(killerConnection.getResponse()); var serverInfoResponse = killerConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -1179,7 +1180,7 @@ public void testRailgunKill() throws Exception { GameConnection observerConnection = createGameConnection("localhost", port); observerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(observerPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(observerPlayerName) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerConnection.getResponse()); @@ -1225,13 +1226,13 @@ public void testPunchKill() throws Exception { GameConnection puncherConnection = createGameConnection("localhost", port); puncherConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(puncherPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(puncherPlayerName) .setGameId(gameIdToConnectTo).build()); GameConnection deadConnection = createGameConnection("localhost", port); deadConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(puncherConnection.getResponse(), 2); ServerResponse puncherPlayerSpawn = puncherConnection.getResponse().poll().get(); @@ -1308,7 +1309,7 @@ public void testPunchKill() throws Exception { assertEquals(WeaponType.PUNCH, killerShootingEvent.getWeaponType()); assertEquals(puncherPlayerId, killerShootingEvent.getPlayer().getPlayerId()); - puncherConnection.write(GetServerInfoCommand.newBuilder().build()); + puncherConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(puncherConnection.getResponse()); var serverInfoResponse = puncherConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -1322,7 +1323,7 @@ public void testPunchKill() throws Exception { GameConnection observerConnection = createGameConnection("localhost", port); observerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName(observerPlayerName) + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName(observerPlayerName) .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(observerConnection.getResponse()); @@ -1365,7 +1366,7 @@ public void testPunchKill() throws Exception { @Test public void testShootDeadPlayer() throws Exception { int gameIdToConnectTo = 0; - var shotgunInfo = ATTACKS_INFO.stream() + var shotgunInfo = AttackStats.getAttacksInfo(RPGPlayerClass.WARRIOR).stream() .filter(attackInfo -> attackInfo.getAttackType() == AttackType.SHOTGUN).findFirst().get(); doReturn(PlayerState.PlayerCoordinates.builder() .position(com.beverly.hills.money.gang.state.entity.Vector.builder().x(0F).y(0F).build()) @@ -1378,12 +1379,12 @@ public void testShootDeadPlayer() throws Exception { GameConnection shooterConnection = createGameConnection("localhost", port); shooterConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); GameConnection deadPlayerConnection = createGameConnection("localhost", port); deadPlayerConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my other player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my other player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); waitUntilQueueNonEmpty(deadPlayerConnection.getResponse()); @@ -1443,7 +1444,7 @@ public void testShootDeadPlayer() throws Exception { "Should be no errors as this situation might happen in a fast paced game"); emptyQueue(shooterConnection.getResponse()); - shooterConnection.write(GetServerInfoCommand.newBuilder().build()); + shooterConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(shooterConnection.getResponse()); var serverInfoResponse = shooterConnection.getResponse().poll().get(); List games = serverInfoResponse.getServerInfo().getGamesList(); @@ -1465,7 +1466,7 @@ public void testShootYourself() throws Exception { GameConnection selfShootingConnection = createGameConnection("localhost", port); selfShootingConnection.write( JoinGameCommand.newBuilder().setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN) - .setPlayerClass(PlayerClass.COMMONER).setPlayerName("my player name") + .setPlayerClass(PlayerClass.WARRIOR).setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilQueueNonEmpty(selfShootingConnection.getResponse()); ServerResponse shooterPlayerSpawn = selfShootingConnection.getResponse().poll().get(); @@ -1498,7 +1499,7 @@ public void testShootYourself() throws Exception { GameConnection gameConnection = createGameConnection("localhost", port); - gameConnection.write(GetServerInfoCommand.newBuilder().build()); + gameConnection.write(GetServerInfoCommand.newBuilder().setPlayerClass(PlayerClass.WARRIOR).build()); waitUntilQueueNonEmpty(gameConnection.getResponse()); ServerResponse serverResponse = gameConnection.getResponse().poll().get(); List games = serverResponse.getServerInfo().getGamesList(); diff --git a/server/src/test/java/com/beverly/hills/money/gang/it/TeleportTest.java b/server/src/test/java/com/beverly/hills/money/gang/it/TeleportTest.java index 77c5be82..333e2a78 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/it/TeleportTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/it/TeleportTest.java @@ -38,6 +38,7 @@ @SetEnvironmentVariable(key = "CLIENT_MAX_SERVER_INACTIVE_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_MOVES_UPDATE_FREQUENCY_MLS", value = "999999") @SetEnvironmentVariable(key = "GAME_SERVER_PLAYER_SPEED_CHECK_FREQUENCY_MLS", value = "1000") + public class TeleportTest extends AbstractGameServerTest { @@ -73,7 +74,7 @@ public void testTeleport() throws IOException, InterruptedException { playerConnection.write( JoinGameCommand.newBuilder() .setVersion(ServerConfig.VERSION).setSkin(PlayerSkinColor.GREEN).setPlayerClass( - PlayerClass.COMMONER) + PlayerClass.WARRIOR) .setPlayerName("my player name") .setGameId(gameIdToConnectTo).build()); waitUntilGetResponses(playerConnection.getResponse(), 2); diff --git a/server/src/test/java/com/beverly/hills/money/gang/state/GameTest.java b/server/src/test/java/com/beverly/hills/money/gang/state/GameTest.java index cbbcdc50..aa99bf68 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/state/GameTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/state/GameTest.java @@ -28,6 +28,7 @@ import com.beverly.hills.money.gang.config.ServerConfig; import com.beverly.hills.money.gang.exception.GameErrorCode; import com.beverly.hills.money.gang.exception.GameLogicError; +import com.beverly.hills.money.gang.factory.RPGStatsFactory; import com.beverly.hills.money.gang.generator.SequenceGenerator; import com.beverly.hills.money.gang.powerup.DefencePowerUp; import com.beverly.hills.money.gang.powerup.HealthPowerUp; @@ -569,12 +570,12 @@ public void testShootDeadBerserkVampireBoost() throws Throwable { String shotPlayerName = "shot player"; Channel channel = mock(Channel.class); PlayerJoinedGameState shooterPlayerConnectedGameState = fullyJoin(shooterPlayerName, - channel, PlayerStateColor.GREEN, RPGPlayerClass.BERSERK); + channel, PlayerStateColor.GREEN, RPGPlayerClass.ANGRY_SKELETON); PlayerJoinedGameState shotPlayerConnectedGameState = fullyJoin(shotPlayerName, channel, PlayerStateColor.GREEN); int shotsToKill = (int) Math.ceil( - 100d / (ServerConfig.DEFAULT_SHOTGUN_DAMAGE * RPGStatsFactory.create(RPGPlayerClass.BERSERK) + 100d / (ServerConfig.DEFAULT_SHOTGUN_DAMAGE * RPGStatsFactory.create(RPGPlayerClass.ANGRY_SKELETON) .getNormalized(PlayerRPGStatType.ATTACK))); // after this loop, one player is almost dead @@ -2161,7 +2162,7 @@ private PlayerJoinedGameState fullyJoin(final String playerName, final Channel p private PlayerJoinedGameState fullyJoin(final String playerName, final Channel playerChannel, PlayerStateColor color) throws GameLogicError { - return fullyJoin(playerName, playerChannel, color, RPGPlayerClass.COMMONER); + return fullyJoin(playerName, playerChannel, color, RPGPlayerClass.WARRIOR); } } diff --git a/server/src/test/java/com/beverly/hills/money/gang/state/PlayerStateTest.java b/server/src/test/java/com/beverly/hills/money/gang/state/PlayerStateTest.java index b97dba3c..26c7bb42 100644 --- a/server/src/test/java/com/beverly/hills/money/gang/state/PlayerStateTest.java +++ b/server/src/test/java/com/beverly/hills/money/gang/state/PlayerStateTest.java @@ -27,7 +27,7 @@ public void tesRegisterKillVampireBoostFullHealth() { PlayerState playerState = new PlayerState( "test player", PlayerState.PlayerCoordinates.builder().build(), 123, PlayerStateColor.GREEN, - RPGPlayerClass.COMMONER); + RPGPlayerClass.WARRIOR); playerState.registerKill(); @@ -46,7 +46,7 @@ public void tesRegisterKillVampireBoostRestoreHealth() { PlayerState playerState = new PlayerState( "test player", PlayerState.PlayerCoordinates.builder().build(), 123, PlayerStateColor.GREEN, - RPGPlayerClass.COMMONER); + RPGPlayerClass.WARRIOR); playerState.getAttacked(AttackType.SHOTGUN, 1); playerState.getAttacked(AttackType.SHOTGUN, 1); @@ -65,7 +65,7 @@ public void tesRegisterKillConcurrent() { PlayerState playerState = new PlayerState( "test player", PlayerState.PlayerCoordinates.builder().build(), 123, PlayerStateColor.GREEN, - RPGPlayerClass.COMMONER); + RPGPlayerClass.WARRIOR); playerState.getAttacked(AttackType.SHOTGUN, 1); playerState.getAttacked(AttackType.SHOTGUN, 1); @@ -116,7 +116,7 @@ public void testMove() { .build(); PlayerState playerState = new PlayerState( "test player", playerOldCoordinates, 123, PlayerStateColor.GREEN, - RPGPlayerClass.COMMONER); + RPGPlayerClass.WARRIOR); playerState.move(playerNewCoordinates, 0); assertEquals(playerNewCoordinates, playerState.getCoordinates()); @@ -140,7 +140,7 @@ public void testMoveSameCoordinates() { .build(); PlayerState playerState = new PlayerState( "test player", playerOldCoordinates, 123, PlayerStateColor.GREEN, - RPGPlayerClass.COMMONER); + RPGPlayerClass.WARRIOR); playerState.move(playerNewCoordinates, 0); playerState.move(playerNewCoordinates, 1); @@ -170,7 +170,7 @@ public void testMoveOutOfOrder() { .build(); PlayerState playerState = new PlayerState( "test player", playerOldCoordinates, 123, PlayerStateColor.GREEN, - RPGPlayerClass.COMMONER); + RPGPlayerClass.WARRIOR); playerState.move(playerNewCoordinates1, 2); playerState.move(playerNewCoordinates2, 1);