summaryrefslogtreecommitdiff
path: root/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Nobel.java
blob: 431f067d4ec3cc483b1bb36490fb15cbbd3b5692 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package  space.m0e.quga.oop.lab56maven.entities.micro;

import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.image.Image;
import javafx.util.Duration;
import  space.m0e.quga.oop.lab56maven.entities.common.Ability;
import space.m0e.quga.oop.lab56maven.entities.macro.Fortress;
import space.m0e.quga.oop.lab56maven.entities.macro.ThroneRoom;
import space.m0e.quga.oop.lab56maven.handlers.DwarfHandler;
import space.m0e.quga.oop.lab56maven.handlers.NobelHandler;

import java.util.ArrayList;
import java.util.Objects;
import java.util.Random;

public class Nobel extends Dwarf {
    public Image spriteImage = new Image(Objects.requireNonNull(Nobel.class.getResourceAsStream("nobel.png")));;
    private ThroneRoom throneRoom;
    public Nobel(String firstName, String lastName, int age, double x, double y, Ability ability) {
        super(firstName, lastName, age, x, y, ability);
        getSprite().setImage(spriteImage);
    }

    public Nobel() {
        this("Edzul", "Èrithbesmar", 35, 0, 0, Ability.values()[new Random().nextInt(Ability.values().length)]);
    }

    public Nobel(Dwarf immigrant, ThroneRoom throneRoom) {
        this(immigrant.getFirstName(), immigrant.getLastName(), immigrant.getAge(), immigrant.getX(), immigrant.getY(), immigrant.getAbility());
        this.setItems(immigrant.getItems());
        this.setHp(this.getHp());
        this.setMaxHp(this.getMaxHp());
        this.setFortress(immigrant.getFortress());
        this.throneRoom = throneRoom;

        this.setHandler(new NobelHandler(this));
        setTimeline(new Timeline(new KeyFrame(Duration.millis(20), this.getHandler())));
        getTimeline().setCycleCount(Animation.INDEFINITE);
    }

    public Nobel(String serializedData) {
        super(serializedData);
    }

}