TowerManager.java 1.26 KB
Newer Older
Akka's avatar
Akka committed
1
2
3
package emu.grasscutter.game.tower;

import dev.morphia.annotations.Entity;
4
import dev.morphia.annotations.Transient;
Akka's avatar
Akka committed
5
6
7
8
9
10
11
12
import emu.grasscutter.data.GameData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.server.packet.send.PacketTowerEnterLevelRsp;

import java.util.List;

@Entity
public class TowerManager {
13
    @Transient private final Player player;
Akka's avatar
Akka committed
14
15
16
17

    public TowerManager(Player player) {
        this.player = player;
    }
18
    
Akka's avatar
Akka committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    private int currentLevel;
    private int currentFloor;

    public void teamSelect(int floor, List<List<Long>> towerTeams) {
        var floorData = GameData.getTowerFloorDataMap().get(floor);

        this.currentFloor = floorData.getFloorId();
        this.currentLevel = floorData.getLevelId();

        player.getTeamManager().setupTemporaryTeam(towerTeams);
    }


    public void enterLevel(int enterPointId) {
        var levelData = GameData.getTowerLevelDataMap().get(currentLevel);
        var id = levelData.getDungeonId();
        // use team user choose
        player.getTeamManager().useTemporaryTeam(0);
        player.getServer().getDungeonManager()
                .enterDungeon(player, enterPointId, id);

        player.getSession().send(new PacketTowerEnterLevelRsp(currentFloor, currentLevel));
    }
}