Create melee weapons system

This commit is contained in:
2022-08-17 17:05:19 +02:00
parent 60132d1bea
commit bbf0109080
9 changed files with 166 additions and 8 deletions

View File

@@ -0,0 +1,29 @@
package com.bartlomiejpluta.demo.world.weapon;
import java.util.Random;
import lombok.*;
import com.bartlomiejpluta.demo.database.model.MeleeWeaponModel;
import com.bartlomiejpluta.demo.entity.Character;
import com.bartlomiejpluta.demo.util.DiceRoller;
public class MeleeWeapon {
private final Random random = new Random();
private final DiceRoller roller;
@Getter
private String name;
@Getter
private int cooldown;
public MeleeWeapon(MeleeWeaponModel template) {
this.name = template.getName();
this.roller = DiceRoller.of(template.getDamage());
this.cooldown = template.getCooldown();
}
public void attack(Character character) {
character.hit(roller.roll());
}
}