Commit a8293102 authored by Melledy's avatar Melledy Committed by GitHub
Browse files

Merge branch 'development' into stable

parents 304b9cb8 ecf7a81a
package emu.grasscutter.game.quest.content;
import emu.grasscutter.game.quest.QuestValue;
import emu.grasscutter.data.excels.QuestData.QuestCondition;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.enums.QuestTrigger;
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
@QuestValue(QuestTrigger.QUEST_CONTENT_NONE)
public class BaseContent extends QuestBaseHandler {
@Override
public boolean execute(GameQuest quest, QuestCondition condition, int... params) {
// TODO Auto-generated method stub
return false;
}
}
package emu.grasscutter.game.quest.content;
import emu.grasscutter.game.quest.QuestValue;
import emu.grasscutter.data.excels.QuestData.QuestCondition;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.enums.QuestTrigger;
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
@QuestValue(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK)
public class ContentCompleteTalk extends QuestBaseHandler {
@Override
public boolean execute(GameQuest quest, QuestCondition condition, int... params) {
return condition.getParam()[0] == params[0];
}
}
package emu.grasscutter.game.quest.content;
import emu.grasscutter.game.quest.QuestValue;
import emu.grasscutter.data.excels.QuestData.QuestCondition;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.enums.QuestTrigger;
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
@QuestValue(QuestTrigger.QUEST_CONTENT_ENTER_DUNGEON)
public class ContentEnterDungeon extends QuestBaseHandler {
@Override
public boolean execute(GameQuest quest, QuestCondition condition, int... params) {
return condition.getParam()[0] == params[0];
}
}
package emu.grasscutter.game.quest.content;
import emu.grasscutter.game.quest.QuestValue;
import emu.grasscutter.data.excels.QuestData.QuestCondition;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.enums.QuestTrigger;
import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
@QuestValue(QuestTrigger.QUEST_CONTENT_FINISH_PLOT)
public class ContentFinishPlot extends QuestBaseHandler {
@Override
public boolean execute(GameQuest quest, QuestCondition condition, int... params) {
return condition.getParam()[0] == params[0];
}
}
package emu.grasscutter.game.quest.enums;
import java.util.Arrays;
public enum LogicType {
LOGIC_NONE (0),
LOGIC_AND (1),
LOGIC_OR (2),
LOGIC_NOT (3),
LOGIC_A_AND_ETCOR (4),
LOGIC_A_AND_B_AND_ETCOR (5),
LOGIC_A_OR_ETCAND (6),
LOGIC_A_OR_B_OR_ETCAND (7),
LOGIC_A_AND_B_OR_ETCAND (8);
private final int value;
LogicType(int id) {
this.value = id;
}
public int getValue() {
return value;
}
public static boolean calculate(LogicType logicType, int[] progress) {
if (logicType == null) {
return progress[0] == 1;
}
switch (logicType) {
case LOGIC_AND -> {
return Arrays.stream(progress).allMatch(i -> i == 1);
}
case LOGIC_OR -> {
return Arrays.stream(progress).anyMatch(i -> i == 1);
}
default -> {
return Arrays.stream(progress).anyMatch(i -> i == 1);
}
}
}
}
package emu.grasscutter.game.quest.enums;
public enum ParentQuestState {
PARENT_QUEST_STATE_NONE (0),
PARENT_QUEST_STATE_FINISHED (1),
PARENT_QUEST_STATE_FAILED (2),
PARENT_QUEST_STATE_CANCELED (3);
private final int value;
ParentQuestState(int id) {
this.value = id;
}
public int getValue() {
return value;
}
}
package emu.grasscutter.game.quest.enums;
public enum QuestGuideType {
QUEST_GUIDE_NONE (0),
QUEST_GUIDE_LOCATION (1),
QUEST_GUIDE_NPC (2);
private final int value;
QuestGuideType(int id) {
this.value = id;
}
public int getValue() {
return value;
}
}
package emu.grasscutter.game.quest.enums;
public enum QuestShowType {
QUEST_SHOW (0),
QUEST_HIDDEN (1);
private final int value;
QuestShowType(int id) {
this.value = id;
}
public int getValue() {
return value;
}
}
package emu.grasscutter.game.quest.enums;
public enum QuestState {
QUEST_STATE_NONE (0),
QUEST_STATE_UNSTARTED (1),
QUEST_STATE_UNFINISHED (2),
QUEST_STATE_FINISHED (3),
QUEST_STATE_FAILED (4);
private final int value;
QuestState(int id) {
this.value = id;
}
public int getValue() {
return value;
}
}
package emu.grasscutter.game.quest.enums;
public enum QuestTrigger {
QUEST_COND_NONE (0),
QUEST_COND_STATE_EQUAL (1),
QUEST_COND_STATE_NOT_EQUAL (2),
QUEST_COND_PACK_HAVE_ITEM (3),
QUEST_COND_AVATAR_ELEMENT_EQUAL (4),
QUEST_COND_AVATAR_ELEMENT_NOT_EQUAL (5),
QUEST_COND_AVATAR_CAN_CHANGE_ELEMENT (6),
QUEST_COND_CITY_LEVEL_EQUAL_GREATER (7),
QUEST_COND_ITEM_NUM_LESS_THAN (8),
QUEST_COND_DAILY_TASK_START (9),
QUEST_COND_OPEN_STATE_EQUAL (10),
QUEST_COND_DAILY_TASK_OPEN (11),
QUEST_COND_DAILY_TASK_REWARD_CAN_GET (12),
QUEST_COND_DAILY_TASK_REWARD_RECEIVED (13),
QUEST_COND_PLAYER_LEVEL_REWARD_CAN_GET (14),
QUEST_COND_EXPLORATION_REWARD_CAN_GET (15),
QUEST_COND_IS_WORLD_OWNER (16),
QUEST_COND_PLAYER_LEVEL_EQUAL_GREATER (17),
QUEST_COND_SCENE_AREA_UNLOCKED (18),
QUEST_COND_ITEM_GIVING_ACTIVED (19),
QUEST_COND_ITEM_GIVING_FINISHED (20),
QUEST_COND_IS_DAYTIME (21),
QUEST_COND_CURRENT_AVATAR (22),
QUEST_COND_CURRENT_AREA (23),
QUEST_COND_QUEST_VAR_EQUAL (24),
QUEST_COND_QUEST_VAR_GREATER (25),
QUEST_COND_QUEST_VAR_LESS (26),
QUEST_COND_FORGE_HAVE_FINISH (27),
QUEST_COND_DAILY_TASK_IN_PROGRESS (28),
QUEST_COND_DAILY_TASK_FINISHED (29),
QUEST_COND_ACTIVITY_COND (30),
QUEST_COND_ACTIVITY_OPEN (31),
QUEST_COND_DAILY_TASK_VAR_GT (32),
QUEST_COND_DAILY_TASK_VAR_EQ (33),
QUEST_COND_DAILY_TASK_VAR_LT (34),
QUEST_COND_BARGAIN_ITEM_GT (35),
QUEST_COND_BARGAIN_ITEM_EQ (36),
QUEST_COND_BARGAIN_ITEM_LT (37),
QUEST_COND_COMPLETE_TALK (38),
QUEST_COND_NOT_HAVE_BLOSSOM_TALK (39),
QUEST_COND_IS_CUR_BLOSSOM_TALK (40),
QUEST_COND_QUEST_NOT_RECEIVE (41),
QUEST_COND_QUEST_SERVER_COND_VALID (42),
QUEST_COND_ACTIVITY_CLIENT_COND (43),
QUEST_COND_QUEST_GLOBAL_VAR_EQUAL (44),
QUEST_COND_QUEST_GLOBAL_VAR_GREATER (45),
QUEST_COND_QUEST_GLOBAL_VAR_LESS (46),
QUEST_COND_PERSONAL_LINE_UNLOCK (47),
QUEST_COND_CITY_REPUTATION_REQUEST (48),
QUEST_COND_MAIN_COOP_START (49),
QUEST_COND_MAIN_COOP_ENTER_SAVE_POINT (50),
QUEST_COND_CITY_REPUTATION_LEVEL (51),
QUEST_COND_CITY_REPUTATION_UNLOCK (52),
QUEST_COND_LUA_NOTIFY (53),
QUEST_COND_CUR_CLIMATE (54),
QUEST_COND_ACTIVITY_END (55),
QUEST_COND_COOP_POINT_RUNNING (56),
QUEST_COND_GADGET_TALK_STATE_EQUAL (57),
QUEST_COND_AVATAR_FETTER_GT (58),
QUEST_COND_AVATAR_FETTER_EQ (59),
QUEST_COND_AVATAR_FETTER_LT (60),
QUEST_COND_NEW_HOMEWORLD_MOUDLE_UNLOCK (61),
QUEST_COND_NEW_HOMEWORLD_LEVEL_REWARD (62),
QUEST_COND_NEW_HOMEWORLD_MAKE_FINISH (63),
QUEST_COND_HOMEWORLD_NPC_EVENT (64),
QUEST_COND_TIME_VAR_GT_EQ (65),
QUEST_COND_TIME_VAR_PASS_DAY (66),
QUEST_COND_HOMEWORLD_NPC_NEW_TALK (67),
QUEST_COND_PLAYER_CHOOSE_MALE (68),
QUEST_COND_HISTORY_GOT_ANY_ITEM (69),
QUEST_COND_LEARNED_RECIPE (70),
QUEST_COND_LUNARITE_REGION_UNLOCKED (71),
QUEST_COND_LUNARITE_HAS_REGION_HINT_COUNT (72),
QUEST_COND_LUNARITE_COLLECT_FINISH (73),
QUEST_COND_LUNARITE_MARK_ALL_FINISH (74),
QUEST_COND_NEW_HOMEWORLD_SHOP_ITEM (75),
QUEST_COND_SCENE_POINT_UNLOCK (76),
QUEST_COND_SCENE_LEVEL_TAG_EQ (77),
QUEST_CONTENT_NONE (0),
QUEST_CONTENT_KILL_MONSTER (1),
QUEST_CONTENT_COMPLETE_TALK (2),
QUEST_CONTENT_MONSTER_DIE (3),
QUEST_CONTENT_FINISH_PLOT (4),
QUEST_CONTENT_OBTAIN_ITEM (5),
QUEST_CONTENT_TRIGGER_FIRE (6),
QUEST_CONTENT_CLEAR_GROUP_MONSTER (7),
QUEST_CONTENT_NOT_FINISH_PLOT (8),
QUEST_CONTENT_ENTER_DUNGEON (9),
QUEST_CONTENT_ENTER_MY_WORLD (10),
QUEST_CONTENT_FINISH_DUNGEON (11),
QUEST_CONTENT_DESTROY_GADGET (12),
QUEST_CONTENT_OBTAIN_MATERIAL_WITH_SUBTYPE (13),
QUEST_CONTENT_NICK_NAME (14),
QUEST_CONTENT_WORKTOP_SELECT (15),
QUEST_CONTENT_SEAL_BATTLE_RESULT (16),
QUEST_CONTENT_ENTER_ROOM (17),
QUEST_CONTENT_GAME_TIME_TICK (18),
QUEST_CONTENT_FAIL_DUNGEON (19),
QUEST_CONTENT_LUA_NOTIFY (20),
QUEST_CONTENT_TEAM_DEAD (21),
QUEST_CONTENT_COMPLETE_ANY_TALK (22),
QUEST_CONTENT_UNLOCK_TRANS_POINT (23),
QUEST_CONTENT_ADD_QUEST_PROGRESS (24),
QUEST_CONTENT_INTERACT_GADGET (25),
QUEST_CONTENT_DAILY_TASK_COMP_FINISH (26),
QUEST_CONTENT_FINISH_ITEM_GIVING (27),
QUEST_CONTENT_SKILL (107),
QUEST_CONTENT_CITY_LEVEL_UP (109),
QUEST_CONTENT_PATTERN_GROUP_CLEAR_MONSTER (110),
QUEST_CONTENT_ITEM_LESS_THAN (111),
QUEST_CONTENT_PLAYER_LEVEL_UP (112),
QUEST_CONTENT_DUNGEON_OPEN_STATUE (113),
QUEST_CONTENT_UNLOCK_AREA (114),
QUEST_CONTENT_OPEN_CHEST_WITH_GADGET_ID (115),
QUEST_CONTENT_UNLOCK_TRANS_POINT_WITH_TYPE (116),
QUEST_CONTENT_FINISH_DAILY_DUNGEON (117),
QUEST_CONTENT_FINISH_WEEKLY_DUNGEON (118),
QUEST_CONTENT_QUEST_VAR_EQUAL (119),
QUEST_CONTENT_QUEST_VAR_GREATER (120),
QUEST_CONTENT_QUEST_VAR_LESS (121),
QUEST_CONTENT_OBTAIN_VARIOUS_ITEM (122),
QUEST_CONTENT_FINISH_TOWER_LEVEL (123),
QUEST_CONTENT_BARGAIN_SUCC (124),
QUEST_CONTENT_BARGAIN_FAIL (125),
QUEST_CONTENT_ITEM_LESS_THAN_BARGAIN (126),
QUEST_CONTENT_ACTIVITY_TRIGGER_FAILED (127),
QUEST_CONTENT_MAIN_COOP_ENTER_SAVE_POINT (128),
QUEST_CONTENT_ANY_MANUAL_TRANSPORT (129),
QUEST_CONTENT_USE_ITEM (130),
QUEST_CONTENT_MAIN_COOP_ENTER_ANY_SAVE_POINT (131),
QUEST_CONTENT_ENTER_MY_HOME_WORLD (132),
QUEST_CONTENT_ENTER_MY_WORLD_SCENE (133),
QUEST_CONTENT_TIME_VAR_GT_EQ (134),
QUEST_CONTENT_TIME_VAR_PASS_DAY (135),
QUEST_CONTENT_QUEST_STATE_EQUAL (136),
QUEST_CONTENT_QUEST_STATE_NOT_EQUAL (137),
QUEST_CONTENT_UNLOCKED_RECIPE (138),
QUEST_CONTENT_NOT_UNLOCKED_RECIPE (139),
QUEST_CONTENT_FISHING_SUCC (140),
QUEST_CONTENT_ENTER_ROGUE_DUNGEON (141),
QUEST_CONTENT_USE_WIDGET (142),
QUEST_CONTENT_CAPTURE_SUCC (143),
QUEST_CONTENT_CAPTURE_USE_CAPTURETAG_LIST (144),
QUEST_CONTENT_CAPTURE_USE_MATERIAL_LIST (145),
QUEST_CONTENT_ENTER_VEHICLE (147),
QUEST_CONTENT_SCENE_LEVEL_TAG_EQ (148),
QUEST_CONTENT_LEAVE_SCENE (149),
QUEST_CONTENT_LEAVE_SCENE_RANGE (150),
QUEST_CONTENT_IRODORI_FINISH_FLOWER_COMBINATION (151),
QUEST_CONTENT_IRODORI_POETRY_REACH_MIN_PROGRESS (152),
QUEST_CONTENT_IRODORI_POETRY_FINISH_FILL_POETRY (153),
QUEST_EXEC_NONE (0),
QUEST_EXEC_DEL_PACK_ITEM (1),
QUEST_EXEC_UNLOCK_POINT (2),
QUEST_EXEC_UNLOCK_AREA (3),
QUEST_EXEC_UNLOCK_FORCE (4),
QUEST_EXEC_LOCK_FORCE (5),
QUEST_EXEC_CHANGE_AVATAR_ELEMET (6),
QUEST_EXEC_REFRESH_GROUP_MONSTER (7),
QUEST_EXEC_SET_IS_FLYABLE (8),
QUEST_EXEC_SET_IS_WEATHER_LOCKED (9),
QUEST_EXEC_SET_IS_GAME_TIME_LOCKED (10),
QUEST_EXEC_SET_IS_TRANSFERABLE (11),
QUEST_EXEC_GRANT_TRIAL_AVATAR (12),
QUEST_EXEC_OPEN_BORED (13),
QUEST_EXEC_ROLLBACK_QUEST (14),
QUEST_EXEC_NOTIFY_GROUP_LUA (15),
QUEST_EXEC_SET_OPEN_STATE (16),
QUEST_EXEC_LOCK_POINT (17),
QUEST_EXEC_DEL_PACK_ITEM_BATCH (18),
QUEST_EXEC_REFRESH_GROUP_SUITE (19),
QUEST_EXEC_REMOVE_TRIAL_AVATAR (20),
QUEST_EXEC_SET_GAME_TIME (21),
QUEST_EXEC_SET_WEATHER_GADGET (22),
QUEST_EXEC_ADD_QUEST_PROGRESS (23),
QUEST_EXEC_NOTIFY_DAILY_TASK (24),
QUEST_EXEC_CREATE_PATTERN_GROUP (25),
QUEST_EXEC_REMOVE_PATTERN_GROUP (26),
QUEST_EXEC_REFRESH_GROUP_SUITE_RANDOM (27),
QUEST_EXEC_ACTIVE_ITEM_GIVING (28),
QUEST_EXEC_DEL_ALL_SPECIFIC_PACK_ITEM (29),
QUEST_EXEC_ROLLBACK_PARENT_QUEST (30),
QUEST_EXEC_LOCK_AVATAR_TEAM (31),
QUEST_EXEC_UNLOCK_AVATAR_TEAM (32),
QUEST_EXEC_UPDATE_PARENT_QUEST_REWARD_INDEX (33),
QUEST_EXEC_SET_DAILY_TASK_VAR (34),
QUEST_EXEC_INC_DAILY_TASK_VAR (35),
QUEST_EXEC_DEC_DAILY_TASK_VAR (36),
QUEST_EXEC_ACTIVE_ACTIVITY_COND_STATE (37),
QUEST_EXEC_INACTIVE_ACTIVITY_COND_STATE (38),
QUEST_EXEC_ADD_CUR_AVATAR_ENERGY (39),
QUEST_EXEC_START_BARGAIN (41),
QUEST_EXEC_STOP_BARGAIN (42),
QUEST_EXEC_SET_QUEST_GLOBAL_VAR (43),
QUEST_EXEC_INC_QUEST_GLOBAL_VAR (44),
QUEST_EXEC_DEC_QUEST_GLOBAL_VAR (45),
QUEST_EXEC_REGISTER_DYNAMIC_GROUP (46),
QUEST_EXEC_UNREGISTER_DYNAMIC_GROUP (47),
QUEST_EXEC_SET_QUEST_VAR (48),
QUEST_EXEC_INC_QUEST_VAR (49),
QUEST_EXEC_DEC_QUEST_VAR (50),
QUEST_EXEC_RANDOM_QUEST_VAR (51),
QUEST_EXEC_ACTIVATE_SCANNING_PIC (52),
QUEST_EXEC_RELOAD_SCENE_TAG (53),
QUEST_EXEC_REGISTER_DYNAMIC_GROUP_ONLY (54),
QUEST_EXEC_CHANGE_SKILL_DEPOT (55),
QUEST_EXEC_ADD_SCENE_TAG (56),
QUEST_EXEC_DEL_SCENE_TAG (57),
QUEST_EXEC_INIT_TIME_VAR (58),
QUEST_EXEC_CLEAR_TIME_VAR (59),
QUEST_EXEC_MODIFY_CLIMATE_AREA (60),
QUEST_EXEC_GRANT_TRIAL_AVATAR_AND_LOCK_TEAM (61),
QUEST_EXEC_CHANGE_MAP_AREA_STATE (62),
QUEST_EXEC_DEACTIVE_ITEM_GIVING (63),
QUEST_EXEC_CHANGE_SCENE_LEVEL_TAG (64),
QUEST_EXEC_UNLOCK_PLAYER_WORLD_SCENE (65),
QUEST_EXEC_LOCK_PLAYER_WORLD_SCENE (66),
QUEST_EXEC_FAIL_MAINCOOP (67),
QUEST_EXEC_MODIFY_WEATHER_AREA (68);
private final int value;
QuestTrigger(int id) {
this.value = id;
}
public int getValue() {
return value;
}
}
package emu.grasscutter.game.quest.enums;
public enum QuestType {
AQ (0),
FQ (1),
LQ (2),
EQ (3),
DQ (4),
IQ (5),
VQ (6),
WQ (7);
private final int value;
QuestType(int id) {
this.value = id;
}
public int getValue() {
return value;
}
}
package emu.grasscutter.game.quest.enums;
public enum ShowQuestGuideType {
QUEST_GUIDE_ITEM_ENABLE (0),
QUEST_GUIDE_ITEM_DISABLE (1),
QUEST_GUIDE_ITEM_MOVE_HIDE (2);
private final int value;
ShowQuestGuideType(int id) {
this.value = id;
}
public int getValue() {
return value;
}
}
package emu.grasscutter.game.quest.handlers;
import emu.grasscutter.data.excels.QuestData.QuestCondition;
import emu.grasscutter.game.quest.GameQuest;
public abstract class QuestBaseHandler {
public abstract boolean execute(GameQuest quest, QuestCondition condition, int... params);
}
package emu.grasscutter.game.shop;
import emu.grasscutter.data.common.ItemParamData;
import emu.grasscutter.data.def.ShopGoodsData;
import emu.grasscutter.data.excels.ShopGoodsData;
import java.util.ArrayList;
import java.util.List;
......
......@@ -2,20 +2,25 @@ package emu.grasscutter.game.shop;
import com.google.gson.reflect.TypeToken;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.DataLoader;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.ItemParamData;
import emu.grasscutter.data.def.ShopGoodsData;
import emu.grasscutter.data.excels.ShopGoodsData;
import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import static emu.grasscutter.Configuration.*;
public class ShopManager {
private final GameServer server;
......@@ -56,7 +61,7 @@ public class ShopManager {
}
private void loadShop() {
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Shop.json")) {
try (Reader fileReader = new InputStreamReader(DataLoader.load("Shop.json"))) {
getShopData().clear();
List<ShopTable> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopTable.class).getType());
if(banners.size() > 0) {
......@@ -84,7 +89,7 @@ public class ShopManager {
Grasscutter.getLogger().error("Unable to load shop data. Shop data size is 0.");
}
if (Grasscutter.getConfig().getGameServerOptions().EnableOfficialShop) {
if (GAME_OPTIONS.enableShopItems) {
GameData.getShopGoodsDataEntries().forEach((k, v) -> {
if (!getShopData().containsKey(k.intValue()))
getShopData().put(k.intValue(), new ArrayList<>());
......@@ -100,7 +105,7 @@ public class ShopManager {
}
private void loadShopChest() {
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "ShopChest.json")) {
try (Reader fileReader = new InputStreamReader(DataLoader.load("ShopChest.json"))) {
getShopChestData().clear();
List<ShopChestTable> shopChestTableList = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopChestTable.class).getType());
if (shopChestTableList.size() > 0) {
......@@ -115,7 +120,7 @@ public class ShopManager {
}
private void loadShopChestBatchUse() {
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "ShopChestBatchUse.json")) {
try (Reader fileReader = new InputStreamReader(DataLoader.load("ShopChestBatchUse.json"))) {
getShopChestBatchUseData().clear();
List<ShopChestBatchUseTable> shopChestBatchUseTableList = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopChestBatchUseTable.class).getType());
if (shopChestBatchUseTableList.size() > 0) {
......
package emu.grasscutter.game.tower;
import dev.morphia.annotations.Entity;
import java.util.HashMap;
import java.util.Map;
@Entity
public class TowerLevelRecord {
/**
* floorId in config
*/
private int floorId;
/**
* LevelId - Stars
*/
private Map<Integer, Integer> passedLevelMap;
private int floorStarRewardProgress;
public TowerLevelRecord setLevelStars(int levelId, int stars){
passedLevelMap.put(levelId, stars);
return this;
}
public int getStarCount() {
return passedLevelMap.values().stream().mapToInt(Integer::intValue).sum();
}
public TowerLevelRecord(){
}
public TowerLevelRecord(int floorId){
this.floorId = floorId;
this.passedLevelMap = new HashMap<>();
this.floorStarRewardProgress = 0;
}
public int getFloorId() {
return floorId;
}
public void setFloorId(int floorId) {
this.floorId = floorId;
}
public Map<Integer, Integer> getPassedLevelMap() {
return passedLevelMap;
}
public void setPassedLevelMap(Map<Integer, Integer> passedLevelMap) {
this.passedLevelMap = passedLevelMap;
}
public int getFloorStarRewardProgress() {
return floorStarRewardProgress;
}
public void setFloorStarRewardProgress(int floorStarRewardProgress) {
this.floorStarRewardProgress = floorStarRewardProgress;
}
}
......@@ -3,15 +3,15 @@ package emu.grasscutter.game.tower;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Transient;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.TowerLevelData;
import emu.grasscutter.data.excels.TowerLevelData;
import emu.grasscutter.game.dungeons.DungeonSettleListener;
import emu.grasscutter.game.dungeons.TowerDungeonSettleListener;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.server.packet.send.PacketTowerCurLevelRecordChangeNotify;
import emu.grasscutter.server.packet.send.PacketTowerEnterLevelRsp;
import emu.grasscutter.server.packet.send.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Entity
public class TowerManager {
......@@ -25,11 +25,19 @@ public class TowerManager {
this.player = player;
}
/**
* the floor players chose
*/
private int currentFloorId;
private int currentLevel;
@Transient
private int currentLevelId;
/**
* floorId - Record
*/
private Map<Integer, TowerLevelRecord> recordMap;
@Transient
private int entryScene;
......@@ -37,66 +45,114 @@ public class TowerManager {
return currentFloorId;
}
public int getCurrentLevelId(){
return this.currentLevelId + currentLevel;
}
/**
* form 1-3
*/
public int getCurrentLevel(){
return currentLevel + 1;
}
private static final List<DungeonSettleListener> towerDungeonSettleListener = List.of(new TowerDungeonSettleListener());
public Map<Integer, TowerLevelRecord> getRecordMap() {
if(recordMap == null){
recordMap = new HashMap<>();
recordMap.put(1001, new TowerLevelRecord(1001));
}
return recordMap;
}
public void teamSelect(int floor, List<List<Long>> towerTeams) {
var floorData = GameData.getTowerFloorDataMap().get(floor);
this.currentFloorId = floorData.getFloorId();
this.currentLevel = 0;
this.currentLevelId = GameData.getTowerLevelDataMap().values().stream()
.filter(x -> x.getLevelId() == floorData.getLevelId() && x.getLevelIndex() == 1)
.filter(x -> x.getLevelGroupId() == floorData.getLevelGroupId() && x.getLevelIndex() == 1)
.findFirst()
.map(TowerLevelData::getID)
.map(TowerLevelData::getId)
.orElse(0);
if (entryScene == 0){
entryScene = player.getSceneId();
}
player.getTeamManager().setupTemporaryTeam(towerTeams);
}
public void enterLevel(int enterPointId) {
var levelData = GameData.getTowerLevelDataMap().get(currentLevelId + currentLevel);
var levelData = GameData.getTowerLevelDataMap().get(getCurrentLevelId());
this.currentLevel++;
var id = levelData.getDungeonId();
var dungeonId = levelData.getDungeonId();
notifyCurLevelRecordChange();
// use team user choose
player.getTeamManager().useTemporaryTeam(0);
player.getServer().getDungeonManager().handoffDungeon(player, id,
player.getServer().getDungeonManager().handoffDungeon(player, dungeonId,
towerDungeonSettleListener);
// make sure user can exit dungeon correctly
player.getScene().setPrevScene(entryScene);
player.getScene().setPrevScenePoint(enterPointId);
player.getSession().send(new PacketTowerEnterLevelRsp(currentFloorId, currentLevel));
player.getSession().send(new PacketTowerEnterLevelRsp(currentFloorId, getCurrentLevel()));
// stop using skill
player.getSession().send(new PacketCanUseSkillNotify(false));
// notify the cond of stars
player.getSession().send(new PacketTowerLevelStarCondNotify(currentFloorId, getCurrentLevel()));
}
public void notifyCurLevelRecordChange(){
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(currentFloorId, currentLevel));
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(currentFloorId, getCurrentLevel()));
}
public void notifyCurLevelRecordChangeWhenDone(){
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(currentFloorId, currentLevel + 1));
public void notifyCurLevelRecordChangeWhenDone(int stars){
if(!recordMap.containsKey(currentFloorId)){
recordMap.put(currentFloorId,
new TowerLevelRecord(currentFloorId).setLevelStars(getCurrentLevelId(),stars));
}else{
recordMap.put(currentFloorId,
recordMap.get(currentFloorId).setLevelStars(getCurrentLevelId(),stars));
}
this.currentLevel++;
if(!hasNextLevel()){
// set up the next floor
recordMap.putIfAbsent(getNextFloorId(), new TowerLevelRecord(getNextFloorId()));
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(getNextFloorId(), 1));
}else{
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(currentFloorId, getCurrentLevel()));
}
}
public boolean hasNextLevel(){
return this.currentLevel < 3;
}
public int getNextFloorId() {
if(hasNextLevel()){
return 0;
}
this.currentFloorId++;
return this.currentFloorId;
return player.getServer().getTowerScheduleManager().getNextFloorId(this.currentFloorId);
}
public boolean hasNextFloor(){
return player.getServer().getTowerScheduleManager().getNextFloorId(this.currentFloorId) > 0;
}
public void clearEntry() {
this.entryScene = 0;
}
public boolean canEnterScheduleFloor(){
if(!recordMap.containsKey(player.getServer().getTowerScheduleManager().getLastEntranceFloor())){
return false;
}
return recordMap.get(player.getServer().getTowerScheduleManager().getLastEntranceFloor())
.getStarCount() >= 6;
}
public void mirrorTeamSetUp(int teamId) {
// use team user choose
player.getTeamManager().useTemporaryTeam(teamId);
player.sendPacket(new PacketTowerMiddleLevelChangeTeamNotify());
}
}
package emu.grasscutter.game.tower;
import java.util.Date;
public class TowerScheduleConfig {
private int scheduleId;
private Date scheduleStartTime;
private Date nextScheduleChangeTime;
public int getScheduleId() {
return scheduleId;
}
public void setScheduleId(int scheduleId) {
this.scheduleId = scheduleId;
}
public Date getScheduleStartTime() {
return scheduleStartTime;
}
public void setScheduleStartTime(Date scheduleStartTime) {
this.scheduleStartTime = scheduleStartTime;
}
public Date getNextScheduleChangeTime() {
return nextScheduleChangeTime;
}
public void setNextScheduleChangeTime(Date nextScheduleChangeTime) {
this.nextScheduleChangeTime = nextScheduleChangeTime;
}
}
package emu.grasscutter.game.tower;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.DataLoader;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.TowerScheduleData;
import emu.grasscutter.server.game.GameServer;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
import static emu.grasscutter.Configuration.*;
public class TowerScheduleManager {
private final GameServer gameServer;
public GameServer getGameServer() {
return gameServer;
}
public TowerScheduleManager(GameServer gameServer) {
this.gameServer = gameServer;
this.load();
}
private TowerScheduleConfig towerScheduleConfig;
public synchronized void load(){
try (Reader fileReader = new InputStreamReader(DataLoader.load("TowerSchedule.json"))) {
towerScheduleConfig = Grasscutter.getGsonFactory().fromJson(fileReader, TowerScheduleConfig.class);
} catch (Exception e) {
Grasscutter.getLogger().error("Unable to load tower schedule config.", e);
}
}
public TowerScheduleConfig getTowerScheduleConfig() {
return towerScheduleConfig;
}
public TowerScheduleData getCurrentTowerScheduleData(){
var data = GameData.getTowerScheduleDataMap().get(towerScheduleConfig.getScheduleId());
if(data == null){
Grasscutter.getLogger().error("Could not get current tower schedule data by schedule id {}, please check your resource files",
towerScheduleConfig.getScheduleId());
}
return data;
}
public List<Integer> getScheduleFloors() {
return getCurrentTowerScheduleData().getSchedules().get(0).getFloorList();
}
public int getNextFloorId(int floorId){
var entranceFloors = getCurrentTowerScheduleData().getEntranceFloorId();
var scheduleFloors = getScheduleFloors();
var nextId = 0;
// find in entrance floors first
for(int i=0;i<entranceFloors.size()-1;i++){
if(floorId == entranceFloors.get(i)){
nextId = entranceFloors.get(i+1);
}
}
if(floorId == entranceFloors.get(entranceFloors.size()-1)){
nextId = scheduleFloors.get(0);
}
if(nextId != 0){
return nextId;
}
// find in schedule floors
for(int i=0; i < scheduleFloors.size() - 1; i++){
if(floorId == scheduleFloors.get(i)){
nextId = scheduleFloors.get(i + 1);
}
}return nextId;
}
public Integer getLastEntranceFloor() {
return getCurrentTowerScheduleData().getEntranceFloorId().get(getCurrentTowerScheduleData().getEntranceFloorId().size() - 1);
}
}
......@@ -2,10 +2,7 @@ package emu.grasscutter.game.world;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameDepot;
import emu.grasscutter.data.def.DungeonData;
import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.data.def.SceneData;
import emu.grasscutter.data.def.WorldLevelData;
import emu.grasscutter.data.excels.*;
import emu.grasscutter.game.dungeons.DungeonChallenge;
import emu.grasscutter.game.dungeons.DungeonSettleListener;
import emu.grasscutter.game.entity.*;
......@@ -105,7 +102,13 @@ public class Scene {
public GameEntity getEntityById(int id) {
return this.entities.get(id);
}
public GameEntity getEntityByConfigId(int configId) {
return this.entities.values().stream()
.filter(x -> x.getConfigId() == configId)
.findFirst()
.orElse(null);
}
/**
* @return the autoCloseTime
*/
......@@ -281,7 +284,7 @@ public class Scene {
private void removePlayerAvatars(Player player) {
Iterator<EntityAvatar> it = player.getTeamManager().getActiveTeam().iterator();
while (it.hasNext()) {
this.removeEntity(it.next(), VisionType.VISION_REMOVE);
this.removeEntity(it.next(), VisionType.VISION_TYPE_REMOVE);
it.remove();
}
}
......@@ -324,7 +327,7 @@ public class Scene {
this.addEntityDirectly(entity);
}
this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_BORN));
this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_TYPE_BORN));
}
private GameEntity removeEntityDirectly(GameEntity entity) {
......@@ -332,7 +335,7 @@ public class Scene {
}
public void removeEntity(GameEntity entity) {
this.removeEntity(entity, VisionType.VISION_DIE);
this.removeEntity(entity, VisionType.VISION_TYPE_DIE);
}
public synchronized void removeEntity(GameEntity entity, VisionType visionType) {
......@@ -345,8 +348,8 @@ public class Scene {
public synchronized void replaceEntity(EntityAvatar oldEntity, EntityAvatar newEntity) {
this.removeEntityDirectly(oldEntity);
this.addEntityDirectly(newEntity);
this.broadcastPacket(new PacketSceneEntityDisappearNotify(oldEntity, VisionType.VISION_REPLACE));
this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VISION_REPLACE, oldEntity.getId()));
this.broadcastPacket(new PacketSceneEntityDisappearNotify(oldEntity, VisionType.VISION_TYPE_REPLACE));
this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VISION_TYPE_REPLACE, oldEntity.getId()));
}
public void showOtherEntities(Player player) {
......@@ -360,7 +363,7 @@ public class Scene {
entities.add(entity);
}
player.sendPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_MEET));
player.sendPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_TYPE_MEET));
}
public void handleAttack(AttackResult result) {
......@@ -379,30 +382,23 @@ public class Scene {
}
// Sanity check
if (target.getFightProperties() == null) {
return;
}
// Lose hp
target.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, -result.getDamage());
// Check if dead
boolean isDead = false;
if (target.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) <= 0f) {
target.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0f);
isDead = true;
}
// Packets
this.broadcastPacket(new PacketEntityFightPropUpdateNotify(target, FightProperty.FIGHT_PROP_CUR_HP));
// Check if dead
if (isDead) {
this.killEntity(target, result.getAttackerId());
}
target.damage(result.getDamage(), result.getAttackerId());
}
public void killEntity(GameEntity target, int attackerId) {
GameEntity attacker = getEntityById(attackerId);
//Check codex
if (attacker instanceof EntityClientGadget) {
var clientGadgetOwner = getEntityById(((EntityClientGadget) attacker).getOwnerEntityId());
if(clientGadgetOwner instanceof EntityAvatar) {
((EntityClientGadget) attacker).getOwner().getCodex().checkAnimal(target, CodexAnimalData.CodexAnimalUnlockCondition.CODEX_COUNT_TYPE_KILL);
}
}
else if (attacker instanceof EntityAvatar) {
((EntityAvatar) attacker).getPlayer().getCodex().checkAnimal(target, CodexAnimalData.CodexAnimalUnlockCondition.CODEX_COUNT_TYPE_KILL);
}
// Packet
this.broadcastPacket(new PacketLifeStateChangeNotify(attackerId, target, LifeState.LIFE_DEAD));
......@@ -469,7 +465,11 @@ public class Scene {
continue;
}
EntityMonster entity = new EntityMonster(this, data, entry.getPos(), worldLevelOverride > 0 ? worldLevelOverride : entry.getLevel());
int level = worldLevelOverride > 0 ? worldLevelOverride + entry.getLevel() - 22 : entry.getLevel();
level = level >= 100 ? 100 : level;
level = level <= 0 ? 1 : level;
EntityMonster entity = new EntityMonster(this, data, entry.getPos(), level);
entity.getRotation().set(entry.getRot());
entity.setGroupId(entry.getGroup().getGroupId());
entity.setPoseId(entry.getPoseId());
......@@ -491,11 +491,11 @@ public class Scene {
if (toAdd.size() > 0) {
toAdd.stream().forEach(this::addEntityDirectly);
this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VISION_BORN));
this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VISION_TYPE_BORN));
}
if (toRemove.size() > 0) {
toRemove.stream().forEach(this::removeEntityDirectly);
this.broadcastPacket(new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_REMOVE));
this.broadcastPacket(new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE));
}
}
......@@ -568,7 +568,7 @@ public class Scene {
if (toRemove.size() > 0) {
toRemove.stream().forEach(this::removeEntityDirectly);
this.broadcastPacket(new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_REMOVE));
this.broadcastPacket(new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE));
}
for (SceneGroup group : block.groups) {
......@@ -613,7 +613,7 @@ public class Scene {
return;
}
this.broadcastPacketToOthers(gadget.getOwner(), new PacketSceneEntityDisappearNotify(gadget, VisionType.VISION_DIE));
this.broadcastPacketToOthers(gadget.getOwner(), new PacketSceneEntityDisappearNotify(gadget, VisionType.VISION_TYPE_DIE));
}
// Broadcasting
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment