Skip to content

Commit

Permalink
Amplify shotgun if players are close (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
beverly-hills-money-gangster authored Aug 23, 2024
1 parent d3812c0 commit e57e20b
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 24 deletions.
8 changes: 4 additions & 4 deletions net-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>daikombat-server</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</parent>

<artifactId>net-client</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>

<properties>
<maven.compiler.source>14</maven.compiler.source>
Expand Down Expand Up @@ -71,12 +71,12 @@
<dependency>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>schema</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</dependency>
<dependency>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>security</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.maven/maven-model -->
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>daikombat-server</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
<packaging>pom</packaging>

<modules>
Expand Down
4 changes: 2 additions & 2 deletions schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>daikombat-server</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</parent>

<artifactId>schema</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>

<properties>
<maven.compiler.source>14</maven.compiler.source>
Expand Down
4 changes: 2 additions & 2 deletions security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>daikombat-server</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</parent>

<artifactId>security</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>

<properties>
<maven.compiler.source>14</maven.compiler.source>
Expand Down
10 changes: 5 additions & 5 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>daikombat-server</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</parent>

<artifactId>server</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>

<properties>
<maven.compiler.source>14</maven.compiler.source>
Expand Down Expand Up @@ -86,12 +86,12 @@
<dependency>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>schema</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</dependency>
<dependency>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>security</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
</dependency>
<dependency>
<groupId>eu.rekawek.toxiproxy</groupId>
Expand Down Expand Up @@ -137,7 +137,7 @@
<dependency>
<groupId>com.beverly.hills.money.gang</groupId>
<artifactId>net-client</artifactId>
<version>11.0.3</version>
<version>11.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package com.beverly.hills.money.gang.state;

import java.util.function.Function;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public enum AttackType {
SHOTGUN, PUNCH, RAILGUN
// shotgun damage increases as the player gets closer to the victim
SHOTGUN(distance -> {
if (distance < 1) {
return 3;
} else if (distance < 2) {
return 2;
}
return 1;
}),
PUNCH(distance -> 1),
RAILGUN(distance -> 1);

@Getter
private final Function<Double, Integer> distanceDamageAmplifier;
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ public PlayerAttackingGameState attack(
LOG.warn("You can't attack a dead player");
return null;
}
attackedPlayer.getAttacked(attackType, attackingPlayerState.getDamageAmplifier());
attackedPlayer.getAttacked(attackType,
attackingPlayerState.getDamageAmplifier(attackedPlayer, attackType));
if (attackedPlayer.isDead()) {
attackingPlayerState.registerKill();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ public void setDefenceAmplifier(int ampl) {
defenceAmplifier.set(ampl);
}

public int getDamageAmplifier() {
return damageAmplifier.get();
public int getDamageAmplifier(PlayerState attackedPlayerState, AttackType attackType) {
var distance = Vector.getDistance(
attackedPlayerState.getCoordinates().position, getCoordinates().position);
return damageAmplifier.get() * attackType.getDistanceDamageAmplifier().apply(distance);
}

public void respawn(final PlayerCoordinates coordinates) {
Expand Down
Loading

0 comments on commit e57e20b

Please sign in to comment.