Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
dde0d8fa38 | |||
11c0c3d97b | |||
0646859959 | |||
17c9af6414 | |||
31a02be28a | |||
334e098dba | |||
efce5e9c11 |
@ -1,6 +1,11 @@
|
||||
|
||||
<p align="center">
|
||||
<img align="center" src="https://w0n.zip/file/5eVXOb">
|
||||
</p>
|
||||
|
||||
<p align="center">Feels like a distant memory</p>
|
||||
|
||||
# WhimsyWorld
|
||||
|
||||

|
||||

|
||||

|
||||
|
@ -3,8 +3,14 @@ package com.alterdekim.game.component;
|
||||
import com.alterdekim.game.component.game.*;
|
||||
import com.alterdekim.game.component.game.friends.OneFR;
|
||||
import com.alterdekim.game.component.game.friends.UserFriend;
|
||||
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
|
||||
import com.alterdekim.game.component.game.home.HomeLocation;
|
||||
import com.alterdekim.game.component.game.home.HomeStuff;
|
||||
import com.alterdekim.game.component.game.inventory.BuyGoodResult;
|
||||
import com.alterdekim.game.component.game.inventory.BuyGoodResultGood;
|
||||
import com.alterdekim.game.component.game.minigame.MiniGameAction;
|
||||
import com.alterdekim.game.component.game.minigame.MultiplayerMinigameLaunch;
|
||||
import com.alterdekim.game.component.game.minigame.MultiplayerMinigameWaiting;
|
||||
import com.alterdekim.game.component.game.response.init.GetUserInfo;
|
||||
import com.alterdekim.game.component.game.response.location.AddUserToLocation;
|
||||
import com.alterdekim.game.component.rtmp.ConnectedProcessor;
|
||||
@ -60,6 +66,9 @@ public class GameServer {
|
||||
@Autowired
|
||||
private MiniGameService miniGameService;
|
||||
|
||||
@Autowired
|
||||
private HomeInventoryService homeInventoryService;
|
||||
|
||||
private final Map<Integer, Player> players;
|
||||
|
||||
private final ObjectMapper xmlMapper;
|
||||
@ -156,6 +165,7 @@ public class GameServer {
|
||||
long requestedLocation = message.getArguments().get(1).getLong();
|
||||
if( requestedLocation == -1L ) {
|
||||
int homePlayerId = message.getArguments().get(0).getInt();
|
||||
log.info("HOME: {}", xmlMapper.writeValueAsString(locationService.getHomeByUserId(homePlayerId)).replace("<", "<"));
|
||||
this.sendResult(playerId, message.getTransactionId(), xmlMapper.writeValueAsString(locationService.getHomeByUserId(homePlayerId)).replace("<", "<"));
|
||||
return;
|
||||
}
|
||||
@ -274,6 +284,60 @@ public class GameServer {
|
||||
case SendGameClose, GameStatistics -> {
|
||||
this.sendResult(playerId, message.getTransactionId(), "0");
|
||||
}
|
||||
case RegisterGameWaiting -> {
|
||||
Map<String, List<MultiplayerMinigameWaiting.Players>> m = new HashMap<>();
|
||||
List<MultiplayerMinigameWaiting.Players> players1 = new ArrayList<>();
|
||||
players1.add(new MultiplayerMinigameWaiting.Players(2, "jerk"));
|
||||
m.put("0", players1);
|
||||
this.call(playerId, CommandType.UpdateRoomTeam, new MultiplayerMinigameWaiting(m, 1, false));
|
||||
players1.add(new MultiplayerMinigameWaiting.Players(3, "dullard"));
|
||||
m.put("0", players1);
|
||||
this.call(playerId, CommandType.UpdateRoomTeam, new MultiplayerMinigameWaiting(m, 1, false));
|
||||
|
||||
this.call(playerId, CommandType.LaunchRoomSession, new MultiplayerMinigameLaunch(m, "222"));
|
||||
|
||||
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("onAddUser", 1, "3"));
|
||||
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("DisplayAvatar", 1, "3"));
|
||||
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("onAddUser", 1, "2"));
|
||||
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("DisplayAvatar", 1, "2"));
|
||||
log.info("Players: {}", players);
|
||||
//this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("OnReady", 0, "2"));
|
||||
//this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("OnReady", 0, "3"));
|
||||
}
|
||||
case GetUserHomeLocationData -> {
|
||||
String xs = xmlMapper.writeValueAsString(
|
||||
new HomeStuff(
|
||||
this.homeInventoryService.getHomeInventoryOfUser(playerId),
|
||||
List.of(new HomeLocation(102, 2, 102L, 54, 708, 0, true, false, true, true, false, ClubAccessType.OPEN, 0, 0, 0.0, 0.0, 0, 0, true, true, true, true))
|
||||
)
|
||||
);
|
||||
log.info("Output: {}", xs);
|
||||
this.sendResult(playerId, message.getTransactionId(), xs);
|
||||
}
|
||||
case SaveLocationChanges -> {
|
||||
if( message.getArguments().size() != 3 ) return;
|
||||
int type = message.getArguments().get(1).getInt();
|
||||
if( type == -2 ) { // home
|
||||
Map<String, AMFObject> info = (Map<String, AMFObject>) message.getArguments().get(2).getRaw();
|
||||
|
||||
if( info.containsKey("Add") ) {
|
||||
Map<String, AMFObject> additions = (Map<String, AMFObject>) info.get("Add").getRaw();
|
||||
this.homeInventoryService.addFurnitureToCurrentHome(playerId, additions);
|
||||
}
|
||||
|
||||
if( info.containsKey("Changes") ) {
|
||||
Map<String, AMFObject> changes = (Map<String, AMFObject>) info.get("Changes").getRaw();
|
||||
this.homeInventoryService.addFurnitureToCurrentHome(playerId, changes);
|
||||
}
|
||||
|
||||
if( info.containsKey("Remove") ) {
|
||||
Map<String, Object> remove = (Map<String, Object>) info.get("Remove").getRaw();
|
||||
this.homeInventoryService.removeFurnitureFromHome(playerId, remove.keySet());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// club
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,7 +347,7 @@ public class GameServer {
|
||||
}
|
||||
|
||||
private void getGame(int playerId, long gameId, double transactionId) throws JsonProcessingException {
|
||||
this.sendResult(playerId, transactionId, xmlMapper.writeValueAsString(miniGameService.findGameById(gameId).get()));
|
||||
this.sendResult(playerId, transactionId, xmlMapper.writeValueAsString(miniGameService.findGameById(gameId).get()).replace("<", "<"));
|
||||
}
|
||||
|
||||
private void lockSomething(int playerId, int what2Lock, Boolean state, UserMessage message) {
|
||||
|
@ -196,23 +196,23 @@ public class StartUpListener {
|
||||
}
|
||||
|
||||
private void pushMiniGames() {
|
||||
miniGameService.save(new MiniGame(0L, "Рентген", 0, 0, 4250, 1d, 2, true, true, false, 0L, 0L, "1", ""));
|
||||
miniGameService.save(new MiniGame(1L, "Дары леса", 10120, 1291, 1749, 10d, 1, true, false, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(2L, "Катер", 10089, 516, 4265, 100d, 1, true, true, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(3L, "Волейбол", 10087, 513, 301, 100d, 1, true, true, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(4L, "Кафе", 10088, 515, 310, 1d, 0, true, true, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(5L, "Труба", 10084, 1104, 11763, 1d, 0, false, true, true, 0L, 0L, "1", ""));
|
||||
miniGameService.save(new MiniGame(6L, "Секретики", 10097, 806, 763, 1d, 0, true, false, true, 1000L, 10000L, "1", ""));
|
||||
miniGameService.save(new MiniGame(7L, "Смешарики", 10086, 510, 3126, 1d, 1, true, true, true, 1000L, 10000L, "0", ""));
|
||||
miniGameService.save(new MiniGame(8L, "Модельер", 10101, 948, 4300, 5d, 0, false, false, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(9L, "Горки", 10095, 557, 341, 40d, 1, true, true, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(10L, "Скачки", 10093, 518, 319, 1d, 0, true, true, true, 1000L, 10000L, "0", ""));
|
||||
miniGameService.save(new MiniGame(11L, "Футбол", 10112, 1212, 4247, 1d, 3, true, true, true, 1000L, 30000L, "0", ""));
|
||||
miniGameService.save(new MiniGame(12L, "Няня", 10083, 505, 4241, 30d, 0, false, true, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(13L, "Двигатель", 10094, 519, 322, 5d, 0, false, true, true, 0L, 0L, "0", ""));
|
||||
miniGameService.save(new MiniGame(14L, "Шарабудка", 8054, 3218, 1127, 1d, 0, false, true, true, 0L, 0L, "1", ""));
|
||||
miniGameService.save(new MiniGame(92L, "Трасса", 0, 0, 4267, 1d, 1, false, false, true, 0L, 0L, "1", ""));
|
||||
miniGameService.save(new MiniGame(206L, "Муравей", 2148, 2148, 3170, 1d, 0, true, false, true, 0L, 0L, "1", ""));
|
||||
miniGameService.save(new MiniGame(0L, "Рентген", 0, 0, 4250, 1d, 2, true, true, false, 0L, 0L, "1", "", ""));
|
||||
miniGameService.save(new MiniGame(1L, "Дары леса", 10120, 1291, 1749, 10d, 1, true, false, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(2L, "Катер", 10089, 516, 4265, 100d, 1, true, true, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(3L, "Волейбол", 10087, 513, 301, 100d, 1, true, true, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(4L, "Кафе", 10088, 515, 310, 1d, 0, true, true, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(5L, "Труба", 10084, 1104, 11763, 1d, 0, false, true, true, 0L, 0L, "1", "", ""));
|
||||
miniGameService.save(new MiniGame(6L, "Секретики", 10097, 806, 763, 1d, 0, true, false, true, 1000L, 10000L, "1", "", "<Groups><item ID=\"0\" MaxUsersCount=\"2\" MinUsersCount=\"2\" /></Groups>"));
|
||||
miniGameService.save(new MiniGame(7L, "Смешарики", 10086, 510, 3126, 1d, 1, true, true, true, 1000L, 10000L, "0", "", "<Groups><item ID=\"0\" MaxUsersCount=\"2\" MinUsersCount=\"2\" /></Groups>"));
|
||||
miniGameService.save(new MiniGame(8L, "Модельер", 10101, 948, 4300, 5d, 0, false, false, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(9L, "Горки", 10095, 557, 341, 40d, 1, true, true, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(10L, "Скачки", 10093, 518, 319, 1d, 0, true, true, true, 1000L, 10000L, "0", "", "<Groups><item ID=\"0\" MaxUsersCount=\"2\" MinUsersCount=\"2\" /></Groups>"));
|
||||
miniGameService.save(new MiniGame(11L, "Футбол", 10112, 1212, 4247, 1d, 3, true, true, true, 1000L, 30000L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(12L, "Няня", 10083, 505, 4241, 30d, 0, false, true, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(13L, "Двигатель", 10094, 519, 322, 5d, 0, false, true, true, 0L, 0L, "0", "", ""));
|
||||
miniGameService.save(new MiniGame(14L, "Шарабудка", 8054, 3218, 1127, 1d, 0, false, true, true, 0L, 0L, "1", "", ""));
|
||||
miniGameService.save(new MiniGame(92L, "Трасса", 0, 0, 4267, 1d, 1, false, false, true, 0L, 0L, "1", "", ""));
|
||||
miniGameService.save(new MiniGame(206L, "Муравей", 2148, 2148, 3170, 1d, 0, true, false, true, 0L, 0L, "1", "", ""));
|
||||
}
|
||||
|
||||
private void pushPhoneSkins() {
|
||||
|
@ -26,6 +26,7 @@ public enum AvatarInventoryType {
|
||||
Smile(-5),
|
||||
House(34),
|
||||
HouseFurniture(20),
|
||||
HouseFurnitureWall(22),
|
||||
Club(58),
|
||||
ClubFacade(63),
|
||||
ClubShow(78),
|
||||
|
@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
public enum CommandType {
|
||||
UserCommand("$"),
|
||||
SetLocation("_LS"),
|
||||
LocationChanges("_LC"),
|
||||
RemoveUserFromLocation("_UL"),
|
||||
AddUserToLocation("_UE"),
|
||||
SetUserAvatarState("_S"),
|
||||
@ -21,6 +22,9 @@ public enum CommandType {
|
||||
AddNewPhoneMessage("_MP"),
|
||||
CardMessage("_MC"),
|
||||
UpdateTickets("_NNT"),
|
||||
UpdateRoomTeam("_GU"),
|
||||
LaunchRoomSession("_GL"),
|
||||
MiniGameAction("_G"),
|
||||
Unknown("");
|
||||
|
||||
private final String value;
|
||||
|
@ -8,6 +8,7 @@ import lombok.Getter;
|
||||
public enum RoleFlags {
|
||||
NONE(0),
|
||||
MEMBER(2),
|
||||
BOSS(4),
|
||||
SA(8),
|
||||
MODERATOR(131072),
|
||||
ADMINISTRATOR(262144),
|
||||
|
@ -43,6 +43,9 @@ public enum UserCommandType {
|
||||
GameScore("_GS"),
|
||||
SendGameClose("_GC"),
|
||||
GameStatistics("_GT"),
|
||||
RegisterGameWaiting("_GR"),
|
||||
GetUserHomeLocationData("_LDH"),
|
||||
SaveLocationChanges("_LC"),
|
||||
Unknown("");
|
||||
|
||||
private final String value;
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.alterdekim.game.component.game.home;
|
||||
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class HomeInventoryGroup {
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "ID")
|
||||
@Getter
|
||||
private String id;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectTypeId")
|
||||
private Integer objectTypeId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectId")
|
||||
@Getter
|
||||
@Setter
|
||||
private Long objectId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectRefTypeId")
|
||||
private Integer objectRefTypeId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
|
||||
private Integer mediaResourceID;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "TextResourceID")
|
||||
private Integer textResourceID;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "object")
|
||||
@JacksonXmlElementWrapper(useWrapping = false, localName = "object")
|
||||
@Getter
|
||||
private List<HomeInventoryObject> object;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.alterdekim.game.component.game.home;
|
||||
|
||||
import com.alterdekim.game.xml.NumericBooleanSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class HomeInventoryObject {
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "ID")
|
||||
private Integer id;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsActive")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isActive;
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.alterdekim.game.component.game.home;
|
||||
|
||||
import com.alterdekim.game.component.game.ClubAccessType;
|
||||
import com.alterdekim.game.xml.ClubAccessTypeSerializer;
|
||||
import com.alterdekim.game.xml.NumericBooleanSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class HomeLocation {
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "ID")
|
||||
private Integer id;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectTypeId")
|
||||
private Integer objectTypeId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectId")
|
||||
private Long objectId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectRefTypeId")
|
||||
private Integer objectRefTypeId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
|
||||
private Integer mediaResourceID;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "TextResourceID")
|
||||
private Integer textResourceID;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsHome")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isHome;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsClub")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isClub;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsVisaAccessPermitted")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean IsVisaAccessPermitted;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsCurrent")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isCurrent;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsLocked")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isLocked;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "ClubAccessType")
|
||||
@JsonSerialize(using = ClubAccessTypeSerializer.class)
|
||||
private ClubAccessType clubAccessType;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "ClubCost")
|
||||
private Integer clubCost;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "ClubRate")
|
||||
private Integer clubRate;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true)
|
||||
private Double x;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true)
|
||||
private Double y;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Frame")
|
||||
private Integer frame;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "TweenerId")
|
||||
private Integer tweenerId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsVisible")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isVisible;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsEnabled")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isEnabled;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsPositionHeld")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isPositionHeld;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsDraggable")
|
||||
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||
private Boolean isDraggable;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.alterdekim.game.component.game.home;
|
||||
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@JacksonXmlRootElement(localName = "root")
|
||||
public class HomeStuff {
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "inventory")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "inventory")
|
||||
private List<HomeInventoryGroup> inventory;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "locations")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "locations")
|
||||
private List<HomeLocation> locations;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.alterdekim.game.component.game.minigame;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class MiniGameAction {
|
||||
private String actionName;
|
||||
private Integer number;
|
||||
private String id;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.alterdekim.game.component.game.minigame;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class MultiplayerMinigameLaunch {
|
||||
private Map<String, List<MultiplayerMinigameWaiting.Players>> players;
|
||||
private String sessionDescriptor;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.alterdekim.game.component.game.minigame;
|
||||
|
||||
import com.alterdekim.game.message.amf.AMFKey;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class MultiplayerMinigameWaiting {
|
||||
private Map<String, List<Players>> players;
|
||||
private Integer number;
|
||||
private Boolean flag;
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Players {
|
||||
@AMFKey(name = "ID")
|
||||
private Integer id;
|
||||
@AMFKey(name = "Name")
|
||||
private String name;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Data
|
||||
@Configuration
|
||||
public class ServerConfig {
|
||||
@Value("${srv.oldMode}") private Boolean oldMode;
|
||||
@Value("${srv.publicDomain}") private String publicDomain;
|
||||
@Value("${srv.rtmpPort}") private Integer gameServerPort;
|
||||
@Value("${srv.resPathSWF}") private String defaultResourcesPath;
|
||||
|
@ -7,11 +7,14 @@ import com.alterdekim.game.component.game.ClubAccessType;
|
||||
import com.alterdekim.game.component.game.PlayerProperties;
|
||||
import com.alterdekim.game.component.game.PlayerPropertyType;
|
||||
import com.alterdekim.game.component.game.RoleFlags;
|
||||
import com.alterdekim.game.component.game.avatar.GoodClothType;
|
||||
import com.alterdekim.game.component.game.inventory.InventoryItem;
|
||||
import com.alterdekim.game.controller.result.api.ApiResult;
|
||||
import com.alterdekim.game.controller.result.api.PreloaderResult;
|
||||
import com.alterdekim.game.controller.result.api.PromotionBannerResult;
|
||||
import com.alterdekim.game.controller.result.api.PromotionResult;
|
||||
import com.alterdekim.game.entity.*;
|
||||
import com.alterdekim.game.repository.AvatarInventoryRepository;
|
||||
import com.alterdekim.game.service.*;
|
||||
import com.alterdekim.game.utils.DateUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@ -19,6 +22,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
@ -69,6 +73,21 @@ public class ApiController {
|
||||
@Autowired
|
||||
private LocationService locationService;
|
||||
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Autowired
|
||||
private MRService mrService;
|
||||
|
||||
@Autowired
|
||||
private MRTService mrtService;
|
||||
|
||||
@Autowired
|
||||
private TRService trService;
|
||||
|
||||
@Autowired
|
||||
private AvatarInventoryRepository avatarInventoryRepository;
|
||||
|
||||
@PostMapping("/delete_row")
|
||||
public ResponseEntity deleteRow(@RequestParam("table") APITable table, @RequestParam("row") Long rowId) {
|
||||
switch (table) {
|
||||
@ -205,6 +224,74 @@ public class ApiController {
|
||||
return ResponseEntity.ok(results);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get_goods", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<GoodResult>> getGoods() {
|
||||
List<GoodResult> results = new LinkedList<>();
|
||||
for( Good good : goodsService.getAll() ) {
|
||||
GoodResult result = new GoodResult();
|
||||
long goodId = good.getId();
|
||||
result.setGoodId(goodId);
|
||||
Integer iconId = -good.getMRId();
|
||||
Integer trId = good.getTRId();
|
||||
var icon = mrService.findById(iconId.longValue());
|
||||
if( icon.isPresent() ) {
|
||||
String url = mrtService.findById(icon.get().getTId().longValue()).getVal() + icon.get().getUrl();
|
||||
result.setUrl(url);
|
||||
}
|
||||
var name = trService.findById(trId.longValue());
|
||||
if( name.isPresent() ) {
|
||||
String text = name.get().getH();
|
||||
result.setName(text);
|
||||
}
|
||||
results.add(result);
|
||||
}
|
||||
return ResponseEntity.ok(results);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get_avatar_inventory", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<GoodResult>> getInventory(@RequestParam("id") Integer userId) {
|
||||
List<GoodResult> results = new LinkedList<>();
|
||||
List<InventoryItem> items = Arrays.stream(GoodClothType.values())
|
||||
.map(type -> this.avatarInventoryRepository.findInventoryItems(userId, type))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
for( InventoryItem avatarInventory : items) {
|
||||
var og = goodsService.findById(avatarInventory.getId());
|
||||
if( og.isPresent() ) {
|
||||
var good = og.get();
|
||||
GoodResult result = new GoodResult();
|
||||
long goodId = good.getId();
|
||||
result.setGoodId(goodId);
|
||||
Integer iconId = -good.getMRId();
|
||||
Integer trId = good.getTRId();
|
||||
var icon = mrService.findById(iconId.longValue());
|
||||
if (icon.isPresent()) {
|
||||
String url = mrtService.findById(icon.get().getTId().longValue()).getVal() + icon.get().getUrl();
|
||||
result.setUrl(url);
|
||||
}
|
||||
var name = trService.findById(trId.longValue());
|
||||
if (name.isPresent()) {
|
||||
String text = name.get().getH();
|
||||
result.setName(text);
|
||||
}
|
||||
results.add(result);
|
||||
}
|
||||
}
|
||||
return ResponseEntity.ok(results);
|
||||
}
|
||||
|
||||
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public static class GoodResult {
|
||||
@JsonProperty
|
||||
private String url;
|
||||
@JsonProperty
|
||||
private Long goodId;
|
||||
@JsonProperty
|
||||
private String name;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class UserPropertyResult {
|
||||
@JsonProperty
|
||||
|
@ -2,7 +2,12 @@ package com.alterdekim.game.controller;
|
||||
|
||||
import com.alterdekim.game.config.ServerConfig;
|
||||
import com.alterdekim.game.controller.result.async.*;
|
||||
import com.alterdekim.game.controller.result.async.old.ResourcesResult;
|
||||
import com.alterdekim.game.controller.result.async.old.ServerActionCDataOld;
|
||||
import com.alterdekim.game.controller.result.async.old.ServerActionMRTS;
|
||||
import com.alterdekim.game.controller.result.async.old.ServerActionResultOld;
|
||||
import com.alterdekim.game.entity.User;
|
||||
import com.alterdekim.game.repository.MagicAbilityRepository;
|
||||
import com.alterdekim.game.security.AuthenticationUtil;
|
||||
import com.alterdekim.game.service.*;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
@ -53,9 +58,24 @@ public class AsyncController {
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
|
||||
@Autowired
|
||||
private MRService mrService;
|
||||
|
||||
@Autowired
|
||||
private TRService trService;
|
||||
|
||||
@Autowired
|
||||
private ROService roService;
|
||||
|
||||
@Autowired
|
||||
private OnlineStatusService onlineStatusService;
|
||||
|
||||
@Autowired
|
||||
private MAService maService;
|
||||
|
||||
@Autowired
|
||||
private MRTService mrtService;
|
||||
|
||||
@PostMapping("/async/Ping")
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> ping() {
|
||||
@ -68,6 +88,90 @@ public class AsyncController {
|
||||
@ResponseBody
|
||||
public ResponseEntity<String> serverAction() {
|
||||
try {
|
||||
if( !serverConfig.getOldMode() ) {
|
||||
return newMode();
|
||||
}
|
||||
return oldMode();
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
private ResponseEntity<String> oldMode() throws JsonProcessingException {
|
||||
User user = AuthenticationUtil.authProfile(userService).get();
|
||||
|
||||
XmlMapper xmlMapper = new XmlMapper();
|
||||
xmlMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
|
||||
xmlMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
|
||||
ServerActionResultOld serverActionResult = new ServerActionResultOld();
|
||||
serverActionResult.setMagicAbilities(maService.getAll());
|
||||
serverActionResult.setSnStatus(new SnStatus(false));
|
||||
serverActionResult.setUsername(new UserName(user.getUsername()));
|
||||
serverActionResult.setFlags(new Flags(true, 13));
|
||||
serverActionResult.setRequests(new Grants(0));
|
||||
serverActionResult.setGrants(new Grants(0));
|
||||
List<ConfigItem> items = new ArrayList<>();
|
||||
items.add(new ConfigItem(1, ServerActionConfigType.IsPreloaderEnabled, "1", "bool")); // play with it
|
||||
items.add(new ConfigItem(2, ServerActionConfigType.SynchronizeAvatarRotation, "1", "bool"));
|
||||
items.add(new ConfigItem(3, ServerActionConfigType.InitialVolumeValue, "30", "number"));
|
||||
items.add(new ConfigItem(4, ServerActionConfigType.IsStartupHomeLocation, "0", "bool"));
|
||||
items.add(new ConfigItem(5, ServerActionConfigType.AccessRoleFlags, "0", "number"));
|
||||
items.add(new ConfigItem(6, ServerActionConfigType.IsInternational, "0", "bool")); // play with it
|
||||
items.add(new ConfigItem(7, ServerActionConfigType.TypeWeapon, "1", "number"));
|
||||
items.add(new ConfigItem(8, ServerActionConfigType.StatisticsSendInterval, "300", "number"));
|
||||
items.add(new ConfigItem(9, ServerActionConfigType.SwfVersion, "", "string"));
|
||||
items.add(new ConfigItem(10, ServerActionConfigType.LanguageId, "1", "number")); // play with it
|
||||
items.add(new ConfigItem(11, ServerActionConfigType.SnId, "1", "number"));
|
||||
items.add(new ConfigItem(12, ServerActionConfigType.AutoServerSelectionAllowed, "0", "bool"));
|
||||
List<ServerItem> s_items = new ArrayList<>();
|
||||
s_items.add(new ServerItem(1, 202, 5, "rtmp://"+serverConfig.getPublicDomain()+":"+serverConfig.getGameServerPort()+"/shararam", 0, 1, 5, 5.1));
|
||||
|
||||
serverActionResult.setPhone(new PhoneMessages(phoneMessageService.getAllByReceiverId(user.getId())));
|
||||
serverActionResult.setMiniquest(miniquestService.getAllMiniquests());
|
||||
serverActionResult.setPostcard(new PostcardMessages(postcardService.getAllPostcardsOfUser(user.getId())));
|
||||
serverActionResult.setPreloader(preloaderService.getSelected());
|
||||
serverActionResult.setPromotion(promotionService.getSelected());
|
||||
serverActionResult.setPromotionBanners(promotionBannerService.getSelected());
|
||||
|
||||
|
||||
List<Tutorial> tutorials = new ArrayList<>();
|
||||
tutorials.add(new Tutorial(-1, 1));
|
||||
tutorials.add(new Tutorial(1, 1));
|
||||
tutorials.add(new Tutorial(2, 1));
|
||||
tutorials.add(new Tutorial(3, 1));
|
||||
tutorials.add(new Tutorial(4, 1));
|
||||
tutorials.add(new Tutorial(5, 1));
|
||||
serverActionResult.setTutorial(tutorials);
|
||||
|
||||
|
||||
serverActionResult.setResources(new ResourcesResult(mrService.getAll(), trService.getAll(), roService.getAll()));
|
||||
|
||||
var config = new ServerActionConfig(items);
|
||||
var system = new ServerActionSystem(1, "cache/resources.swf"); // swf/cache/rus/resources[19].swf
|
||||
ServerActionUser userdata = null;
|
||||
ServerActionServers servers = null;
|
||||
if( !user.getIsBanned() ) {
|
||||
userdata = new ServerActionUser(user.getId(), AuthenticationUtil.getToken(user), AuthenticationUtil.getToken(user), 2, null, null);
|
||||
servers = new ServerActionServers(s_items);
|
||||
} else {
|
||||
userdata = new ServerActionUser(user.getId(), null, null, 0, LocalDateTime.now(), 162L);
|
||||
}
|
||||
List<ServerActionCData> cdatas = new ArrayList<>();
|
||||
cdatas.add(userdata);
|
||||
cdatas.add(config);
|
||||
cdatas.add(system);
|
||||
cdatas.add(servers);
|
||||
cdatas.add(new ServerActionMRTS(mrtService.getAll()));
|
||||
//serverActionResult.setCdata(new ServerActionCDataOld(userdata, config, system, servers, mrtService.getAll()));
|
||||
log.info("serverActionResult: {}", serverActionResult);
|
||||
serverActionResult.setCdata(cdatas);
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_XML)
|
||||
.body(xmlMapper.writeValueAsString(serverActionResult));
|
||||
}
|
||||
|
||||
private ResponseEntity<String> newMode() throws JsonProcessingException {
|
||||
User user = AuthenticationUtil.authProfile(userService).get();
|
||||
|
||||
XmlMapper xmlMapper = new XmlMapper();
|
||||
@ -125,9 +229,5 @@ public class AsyncController {
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_XML)
|
||||
.body(xmlMapper.writeValueAsString(serverActionResult));
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,8 @@ public class SignUpController {
|
||||
avatarInventoryService.addPhoneToInventory(userId, 1L);
|
||||
avatarInventoryService.addBackgroundToInventory(userId, 339L);
|
||||
|
||||
avatarInventoryService.addGoodToInventory(new AvatarInventory(referenceLoader.getUserReference(userId), 102L, true, AvatarInventoryType.House));
|
||||
|
||||
try {
|
||||
av.getInventory()
|
||||
.stream()
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.alterdekim.game.controller;
|
||||
|
||||
import com.alterdekim.game.component.ReferenceLoader;
|
||||
import com.alterdekim.game.component.game.AvatarInventoryType;
|
||||
import com.alterdekim.game.config.ServerConfig;
|
||||
import com.alterdekim.game.entity.AvatarInventory;
|
||||
import com.alterdekim.game.entity.Role;
|
||||
import com.alterdekim.game.entity.User;
|
||||
import com.alterdekim.game.security.AuthenticationUtil;
|
||||
import com.alterdekim.game.service.AvatarInventoryService;
|
||||
import com.alterdekim.game.service.GoodsService;
|
||||
import com.alterdekim.game.service.UserService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -44,6 +48,12 @@ public class StaticController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private ReferenceLoader referenceLoader;
|
||||
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
@GetMapping("/main")
|
||||
public String mainPage(Model model) {
|
||||
User user = AuthenticationUtil.authProfile(userService).get();
|
||||
@ -72,9 +82,32 @@ public class StaticController {
|
||||
public String panelUser(Model model, @RequestParam(value = "id", defaultValue = "1") Integer userId) {
|
||||
model.addAttribute("user_id", userId);
|
||||
model.addAttribute("user_name", userService.getUsernameById(userId).get());
|
||||
model.addAttribute("inventory_link", "/panel_inventory?id="+userId);
|
||||
return "panel_user";
|
||||
}
|
||||
|
||||
@GetMapping("/panel_inventory")
|
||||
public String panelInventory(Model model, @RequestParam(value = "id", defaultValue = "1") Integer userId) {
|
||||
model.addAttribute("user_id", userId);
|
||||
model.addAttribute("user_name", "Inventory of " + userService.getUsernameById(userId).get());
|
||||
return "panel_inventory";
|
||||
}
|
||||
|
||||
@PostMapping("/panel_inventory")
|
||||
public String panelInventory(Model model, @RequestParam(value = "id", defaultValue = "1") Integer userId, @RequestParam(value = "good_id") Long goodId) {
|
||||
model.addAttribute("user_id", userId);
|
||||
model.addAttribute("user_name", "Inventory of " + userService.getUsernameById(userId).get());
|
||||
|
||||
userService.pushToInventory(userId, AvatarInventoryType.fromGoodId(goodsService, goodId), goodId);
|
||||
|
||||
return "redirect:/panel_inventory?id="+userId;
|
||||
}
|
||||
|
||||
@GetMapping("/goods")
|
||||
public String goodsPage() {
|
||||
return "goods";
|
||||
}
|
||||
|
||||
public enum PanelSection {
|
||||
Dashboard,
|
||||
Locations,
|
||||
|
@ -3,7 +3,9 @@ package com.alterdekim.game.controller.result.async;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
public class UserName {
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Value")
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.alterdekim.game.controller.result.async.old;
|
||||
|
||||
import com.alterdekim.game.entity.MediaResource;
|
||||
import com.alterdekim.game.entity.ResourceObject;
|
||||
import com.alterdekim.game.entity.TextResource;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResourcesResult {
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "MediaResources")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "MediaResources")
|
||||
private List<MediaResource> mediaResources;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "TextResources")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "TextResources")
|
||||
private List<TextResource> textResources;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "ResourcesOptions")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "ResourcesOptions")
|
||||
private List<ResourceObject> resourceOptions;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.alterdekim.game.controller.result.async.old;
|
||||
|
||||
|
||||
import com.alterdekim.game.controller.result.async.ServerActionConfig;
|
||||
import com.alterdekim.game.controller.result.async.ServerActionServers;
|
||||
import com.alterdekim.game.controller.result.async.ServerActionSystem;
|
||||
import com.alterdekim.game.controller.result.async.ServerActionUser;
|
||||
import com.alterdekim.game.entity.MediaResourcePath;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class ServerActionCDataOld {
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "user")
|
||||
private ServerActionUser user;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "config")
|
||||
private ServerActionConfig config;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "system")
|
||||
private ServerActionSystem system;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "servers")
|
||||
private ServerActionServers servers;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "mrtroot")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "mrtroot")
|
||||
private List<MediaResourcePath> mrtRoot;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.alterdekim.game.controller.result.async.old;
|
||||
|
||||
import com.alterdekim.game.controller.result.async.ServerActionCData;
|
||||
import com.alterdekim.game.entity.MediaResourcePath;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@JsonRootName(value = "mrtroot")
|
||||
public class ServerActionMRTS extends ServerActionCData {
|
||||
@JacksonXmlElementWrapper(useWrapping = false, localName = "mrtroot")
|
||||
private List<MediaResourcePath> mrtRoot;
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.alterdekim.game.controller.result.async.old;
|
||||
|
||||
import com.alterdekim.game.controller.result.async.*;
|
||||
import com.alterdekim.game.entity.*;
|
||||
import com.alterdekim.game.xml.CryptoSerializer;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
@JsonRootName(value = "response")
|
||||
public class ServerActionResultOld {
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "user_name")
|
||||
private UserName username;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = false, localName = "sn_status")
|
||||
private SnStatus snStatus;
|
||||
|
||||
@JacksonXmlProperty
|
||||
private List<Preloader> preloader;
|
||||
|
||||
@JacksonXmlProperty(localName = "magic_abilities")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "magic_abilities")
|
||||
private List<MagicAbility> magicAbilities;
|
||||
|
||||
@JacksonXmlProperty
|
||||
private Flags flags;
|
||||
|
||||
@JacksonXmlProperty(localName = "tutorial")
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "tutorial")
|
||||
private List<Tutorial> tutorial;
|
||||
|
||||
@JacksonXmlProperty
|
||||
private Grants grants;
|
||||
|
||||
@JacksonXmlProperty
|
||||
private Grants requests;
|
||||
|
||||
@JacksonXmlProperty
|
||||
private List<Promotion> promotion;
|
||||
|
||||
@JacksonXmlProperty(localName = "promotion_banner")
|
||||
private List<PromotionBanner> promotionBanners;
|
||||
|
||||
@JacksonXmlProperty
|
||||
private PhoneMessages phone;
|
||||
|
||||
@JacksonXmlProperty
|
||||
private PostcardMessages postcard;
|
||||
|
||||
@JacksonXmlProperty
|
||||
@JacksonXmlElementWrapper(useWrapping = true, localName = "miniquest")
|
||||
private List<Miniquest> miniquest;
|
||||
|
||||
@JacksonXmlProperty(localName = "resources")
|
||||
private ResourcesResult resources;
|
||||
|
||||
@JacksonXmlProperty(localName = "cdata")
|
||||
@JsonSerialize(using = CryptoSerializer.class)
|
||||
@JacksonXmlElementWrapper(useWrapping = false, localName = "cdata")
|
||||
private List<ServerActionCData> cdata;
|
||||
}
|
47
src/main/java/com/alterdekim/game/entity/HouseInventory.java
Normal file
47
src/main/java/com/alterdekim/game/entity/HouseInventory.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.alterdekim.game.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name="house_inventory")
|
||||
public class HouseInventory {
|
||||
@jakarta.persistence.Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long Id;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(referencedColumnName = "id")
|
||||
private User user;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Long goodId;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Long homeId;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Double x;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Double y;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer frame;
|
||||
|
||||
public HouseInventory(User user, Long goodId, Long homeId, Double x, Double y, Integer frame) {
|
||||
this.user = user;
|
||||
this.goodId = goodId;
|
||||
this.homeId = homeId;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.frame = frame;
|
||||
}
|
||||
}
|
@ -22,32 +22,44 @@ public class LocationObjectInstance implements ApiResult {
|
||||
private Long id;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectTypeId")
|
||||
@Column(nullable = false)
|
||||
private Integer objectTypeId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectId")
|
||||
@Column(nullable = false)
|
||||
private Integer objectId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "AObjectRefId")
|
||||
@Column(nullable = false)
|
||||
private Integer objectReferenceId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
|
||||
@Column(nullable = false)
|
||||
private Long mediaResourceId;
|
||||
|
||||
@JsonIgnore
|
||||
@Column(nullable = false)
|
||||
private Long locationId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "x")
|
||||
@Column(nullable = false)
|
||||
private Double x;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "y")
|
||||
@Column(nullable = false)
|
||||
private Double y;
|
||||
|
||||
@JacksonXmlText
|
||||
@Column(nullable = false)
|
||||
private String options;
|
||||
|
||||
@JsonIgnore
|
||||
@Column(nullable = false)
|
||||
private String comment;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Frame")
|
||||
private Integer frame;
|
||||
|
||||
@Override
|
||||
public LocationObjectInstanceResult toAPIResult() {
|
||||
return new LocationObjectInstanceResult(this.id, this.objectTypeId, this.objectId, this.objectReferenceId, this.mediaResourceId, this.locationId, this.x, this.y, this.options, this.comment);
|
||||
|
@ -4,6 +4,7 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashField;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValue;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValueType;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
@ -21,26 +22,32 @@ import lombok.*;
|
||||
public class MagicAbility {
|
||||
@Id
|
||||
@FlashValue(type = FlashValueType.Id)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Id")
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
@FlashField(name = "TypeId")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "TypeId")
|
||||
private Integer typeId;
|
||||
|
||||
@Column(nullable = true)
|
||||
@FlashField(name = "duration")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Duration")
|
||||
private Integer duration;
|
||||
|
||||
@Column(nullable = true)
|
||||
@FlashField(name = "TweenerId")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "TweenerId")
|
||||
private Integer tweenerId;
|
||||
|
||||
@Column(nullable = false)
|
||||
@FlashField(name = "MRId")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
|
||||
private Integer mediaResourceId;
|
||||
|
||||
@Column(nullable = false)
|
||||
@FlashField(name = "TRId")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "TRId")
|
||||
private Integer textResourceId;
|
||||
|
||||
@Column(nullable = false)
|
||||
@ -53,5 +60,6 @@ public class MagicAbility {
|
||||
|
||||
@Column(nullable = true)
|
||||
@FlashField(name = "IsMovable")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "IsMovable")
|
||||
private Boolean isMovable;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashField;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValue;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValueType;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
@ -20,17 +21,21 @@ import lombok.*;
|
||||
@FlashClass(name = "mr")
|
||||
public class MediaResource {
|
||||
@Id
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Id")
|
||||
@FlashValue(type = FlashValueType.Id)
|
||||
private Long id;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "TId")
|
||||
@FlashField(name = "TId")
|
||||
@Column(nullable = false)
|
||||
private Integer tId;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Url")
|
||||
@FlashField(name = "Url")
|
||||
@Column(nullable = false)
|
||||
private String url;
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "V")
|
||||
@FlashField(name = "V")
|
||||
@Column(nullable = true)
|
||||
private String v;
|
||||
|
@ -3,6 +3,7 @@ package com.alterdekim.game.entity;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashClass;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValue;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValueType;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
@ -19,10 +20,12 @@ import lombok.*;
|
||||
@FlashClass(name = "mrt")
|
||||
public class MediaResourcePath {
|
||||
@Id
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Id")
|
||||
@FlashValue(type = FlashValueType.Id)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false)
|
||||
@FlashValue(type = FlashValueType.Value)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Url")
|
||||
private String val;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.alterdekim.flash.decompiler.mapper.FlashValueType;
|
||||
import com.alterdekim.game.xml.NumericBooleanSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
@ -77,4 +78,8 @@ public class MiniGame {
|
||||
@Column(nullable = false)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Token")
|
||||
private String token;
|
||||
|
||||
@Column(nullable = false)
|
||||
@JacksonXmlText
|
||||
private String groups_list;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashField;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValue;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValueType;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
@ -21,22 +22,27 @@ import lombok.*;
|
||||
public class ResourceObject {
|
||||
@Id
|
||||
@FlashValue(type = FlashValueType.Id)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Id")
|
||||
private Long id;
|
||||
|
||||
@FlashField(name = "X")
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "X")
|
||||
@Column(nullable = true)
|
||||
private Double x;
|
||||
|
||||
@FlashField(name = "Y")
|
||||
@Column(nullable = true)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Y")
|
||||
private Double y;
|
||||
|
||||
@FlashField(name = "Width")
|
||||
@Column(nullable = true)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Width")
|
||||
private Double width;
|
||||
|
||||
@FlashField(name = "Height")
|
||||
@Column(nullable = true)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Height")
|
||||
private Double height;
|
||||
|
||||
@FlashField(name = "IsCloseHide")
|
||||
|
@ -4,6 +4,7 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashField;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValue;
|
||||
import com.alterdekim.flash.decompiler.mapper.FlashValueType;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
@ -21,13 +22,16 @@ import lombok.*;
|
||||
public class TextResource {
|
||||
@Id
|
||||
@FlashValue(type = FlashValueType.Id)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "Id")
|
||||
private Long id;
|
||||
|
||||
@FlashField(name = "OId")
|
||||
@Column(nullable = true)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "OId")
|
||||
private Integer oId;
|
||||
|
||||
@FlashField(name = "H")
|
||||
@Column(nullable = false, length = 65555)
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "H")
|
||||
private String h;
|
||||
}
|
||||
|
@ -72,7 +72,9 @@ public class AMFDeserializer {
|
||||
a.clear();
|
||||
if( keyLen == 0 ) {
|
||||
endMarker = true;
|
||||
if( !bytes.isEmpty() ) {
|
||||
bytes.remove();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
a = bytes.subList(0, Math.min(keyLen, bytes.size()));
|
||||
@ -104,7 +106,9 @@ public class AMFDeserializer {
|
||||
a.clear();
|
||||
if( keyLen == 0 ) {
|
||||
endMarker = true;
|
||||
if( !bytes.isEmpty() ) {
|
||||
bytes.remove();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
bytes.subList(0, Math.min(keyLen, bytes.size())).clear();
|
||||
|
@ -64,6 +64,9 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
|
||||
WHERE a.user_id = :uid AND a.type = :#{#goodTypeId.getVal().name()}""", nativeQuery = true)
|
||||
List<InventoryItem> findInventoryItems(@Param("uid") Integer userId, @Param("goodTypeId") GoodClothType goodClothType);
|
||||
|
||||
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid")
|
||||
List<AvatarInventory> findAllByUserId(@Param("uid") Integer userId);
|
||||
|
||||
@Query(value = """
|
||||
SELECT
|
||||
b.id AS id,
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.alterdekim.game.repository;
|
||||
|
||||
import com.alterdekim.game.entity.HouseInventory;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface HouseInventoryRepository extends JpaRepository<HouseInventory, Long> {
|
||||
|
||||
@Query(value = "SELECT h FROM HouseInventory h WHERE h.user.id = :uid")
|
||||
List<HouseInventory> findByUserId(@Param("uid") int userId);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query(value = "UPDATE HouseInventory h SET h.homeId = :houseId, h.x = :x, h.y = :y, h.frame = :frame WHERE h.id = :uid")
|
||||
void updateInfoById(@Param("uid") Long id, @Param("houseId") Long houseId, @Param("x") Double x, @Param("y") Double y, @Param("frame") Integer frame);
|
||||
|
||||
@Query(value = "SELECT h FROM HouseInventory h WHERE h.user.id = :uid AND h.homeId = :houseId")
|
||||
List<HouseInventory> findByUserIdAndHouseId(@Param("uid") Integer userId, @Param("houseId") Long houseId);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query(value = "UPDATE HouseInventory h SET h.homeId = -1 WHERE h.id = :uid")
|
||||
void resetHomeId(@Param("uid") Long id);
|
||||
}
|
@ -38,6 +38,8 @@ public class SpringSecurity {
|
||||
.requestMatchers("/login").permitAll()
|
||||
.requestMatchers("/panel").hasAuthority(Role.RoleType.RoleAdmin.name())
|
||||
.requestMatchers("/panel_user").hasAuthority(Role.RoleType.RoleAdmin.name())
|
||||
.requestMatchers("/panel_inventory").hasAuthority(Role.RoleType.RoleAdmin.name())
|
||||
.requestMatchers("/goods").hasAuthority(Role.RoleType.RoleAdmin.name())
|
||||
.requestMatchers("/api/**").hasAuthority(Role.RoleType.RoleAdmin.name())
|
||||
.requestMatchers("/main").hasAnyAuthority(Role.RoleType.RoleUser.name(), Role.RoleType.RoleAdmin.name())
|
||||
.requestMatchers("/"+ FileServerController.URL_PATH +"/**").permitAll()
|
||||
|
@ -6,6 +6,8 @@ import com.alterdekim.game.component.game.avatar.IBodyAvatarItem;
|
||||
import com.alterdekim.game.component.game.avatar.BodyPartType;
|
||||
import com.alterdekim.game.component.game.avatar.GoodClothType;
|
||||
import com.alterdekim.game.component.game.avatar.InitMagicAbility;
|
||||
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
|
||||
import com.alterdekim.game.component.game.home.HomeInventoryObject;
|
||||
import com.alterdekim.game.component.game.inventory.InventoryGroup;
|
||||
import com.alterdekim.game.component.game.inventory.InventoryItem;
|
||||
import com.alterdekim.game.controller.result.signup.AvatarBodyPart;
|
||||
@ -227,11 +229,9 @@ public class AvatarInventoryService {
|
||||
.findFirst().orElse(0L);
|
||||
}
|
||||
|
||||
public Long getUsedHouse(Integer userId) {
|
||||
public Optional<AvatarInventory> getUsedHouse(Integer userId) {
|
||||
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.House)
|
||||
.stream()
|
||||
.map(AvatarInventory::getGoodId)
|
||||
.findFirst().orElse(0L);
|
||||
.stream().findFirst();
|
||||
}
|
||||
|
||||
public String getAchievementsByUserId(Integer userId) {
|
||||
|
@ -7,6 +7,7 @@ import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@ -25,4 +26,8 @@ public class GoodsService implements OutputObjectCallback {
|
||||
public Optional<Good> findById(Long id) {
|
||||
return this.repository.findById(id);
|
||||
}
|
||||
|
||||
public List<Good> getAll() {
|
||||
return this.repository.findAll();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,90 @@
|
||||
package com.alterdekim.game.service;
|
||||
|
||||
import com.alterdekim.game.component.ReferenceLoader;
|
||||
import com.alterdekim.game.component.game.AvatarInventoryType;
|
||||
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
|
||||
import com.alterdekim.game.component.game.home.HomeInventoryObject;
|
||||
import com.alterdekim.game.entity.AvatarInventory;
|
||||
import com.alterdekim.game.entity.Good;
|
||||
import com.alterdekim.game.entity.HouseInventory;
|
||||
import com.alterdekim.game.message.amf.AMFObject;
|
||||
import com.alterdekim.game.repository.AvatarInventoryRepository;
|
||||
import com.alterdekim.game.repository.GoodRepository;
|
||||
import com.alterdekim.game.repository.HouseInventoryRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.javatuples.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HomeInventoryService {
|
||||
|
||||
@Autowired
|
||||
private HouseInventoryRepository houseInventoryRepository;
|
||||
|
||||
@Autowired
|
||||
private AvatarInventoryRepository avatarInventoryRepository;
|
||||
|
||||
@Autowired
|
||||
private GoodRepository goodRepository;
|
||||
|
||||
public void removeFurnitureFromHome(int userId, Set<String> ids) {
|
||||
for( String id : ids ) {
|
||||
houseInventoryRepository.resetHomeId(Long.parseLong(id));
|
||||
}
|
||||
}
|
||||
|
||||
public void addFurnitureToCurrentHome(int userId, Map<String, AMFObject> additions) {
|
||||
Set<String> ids = additions.keySet();
|
||||
long houseId = getCurrentHouseId(userId);
|
||||
for( String id : ids ) {
|
||||
Map<String, AMFObject> obj = (Map<String, AMFObject>) additions.get(id).getRaw();
|
||||
Integer frame = obj.containsKey("Frame") ? obj.get("Frame").getInt() : 0;
|
||||
houseInventoryRepository.updateInfoById(Long.parseLong(id), houseId, obj.get("x").getDouble(), obj.get("y").getDouble(), frame);
|
||||
}
|
||||
}
|
||||
|
||||
private long getCurrentHouseId(int userId) {
|
||||
return avatarInventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.House).stream()
|
||||
.findFirst()
|
||||
.map(AvatarInventory::getId)
|
||||
.orElse(-1L);
|
||||
}
|
||||
|
||||
public List<HomeInventoryGroup> getHomeInventoryOfUser(int userId) {
|
||||
|
||||
List<HomeInventoryGroup> groups = this.houseInventoryRepository.findByUserId(userId)
|
||||
.stream()
|
||||
.map(HouseInventory::getGoodId)
|
||||
.distinct()
|
||||
.map(i -> goodRepository.findById(i))
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.map(i -> new HomeInventoryGroup("1$"+i.getId(),
|
||||
1,
|
||||
i.getId(),
|
||||
i.getGoodTypeId(),
|
||||
i.getMRId(),
|
||||
i.getTRId(),
|
||||
new ArrayList<>()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
this.houseInventoryRepository.findByUserId(userId)
|
||||
.forEach(i -> {
|
||||
for( HomeInventoryGroup group : groups ) {
|
||||
if( group.getObjectId() == i.getGoodId().longValue() ) {
|
||||
group.getObject().add(new HomeInventoryObject(i.getId().intValue(), i.getHomeId() != -1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return groups;
|
||||
}
|
||||
}
|
@ -2,14 +2,8 @@ package com.alterdekim.game.service;
|
||||
|
||||
import com.alterdekim.game.component.game.PlayerProperties;
|
||||
import com.alterdekim.game.component.game.response.location.LocationObject;
|
||||
import com.alterdekim.game.entity.Good;
|
||||
import com.alterdekim.game.entity.HouseLocation;
|
||||
import com.alterdekim.game.entity.Location;
|
||||
import com.alterdekim.game.entity.LocationObjectInstance;
|
||||
import com.alterdekim.game.repository.GoodRepository;
|
||||
import com.alterdekim.game.repository.HouseLocationRepository;
|
||||
import com.alterdekim.game.repository.LocationObjectInstanceRepository;
|
||||
import com.alterdekim.game.repository.LocationRepository;
|
||||
import com.alterdekim.game.entity.*;
|
||||
import com.alterdekim.game.repository.*;
|
||||
import com.alterdekim.game.utils.GameUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -17,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class LocationService {
|
||||
@ -39,6 +34,9 @@ public class LocationService {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private HouseInventoryRepository houseInventoryRepository;
|
||||
|
||||
public List<LocationObjectInstance> getAllLocationObjects() {
|
||||
return this.locationObjectInstanceRepository.findAll();
|
||||
}
|
||||
@ -83,9 +81,26 @@ public class LocationService {
|
||||
|
||||
|
||||
public LocationObject getHomeByUserId(Integer userId) {
|
||||
Long goodId = goodRepository.findById(avatarInventoryService.getUsedHouse(userId)).map(Good::getId).orElse(102L);
|
||||
Long goodId = avatarInventoryService.getUsedHouse(userId).map(AvatarInventory::getGoodId).orElse(102L);
|
||||
var house = this.houseLocationRepository.findDefaultHouseLocationByGoodId(goodId).get();
|
||||
return new LocationObject(GameUtils.convertToSpecialLocation(userId, true), true, false, userService.getBooleanUserProperty(userId, PlayerProperties.IsHomeLocked, true), true, house.getMediaResourceId().longValue(), 300.0, 300.0, "", userId, userService.getUsernameById(userId).get(), Collections.emptyList());
|
||||
return new LocationObject(GameUtils.convertToSpecialLocation(userId, true), true, false, userService.getBooleanUserProperty(userId, PlayerProperties.IsHomeLocked, true), true, house.getMediaResourceId().longValue(), 300.0, 300.0, "", userId, userService.getUsernameById(userId).get(),
|
||||
houseInventoryRepository.findByUserIdAndHouseId(userId, avatarInventoryService.getUsedHouse(userId).map(AvatarInventory::getId).orElse(-1L))
|
||||
.stream()
|
||||
.map(h -> new LocationObjectInstance(
|
||||
h.getId(),
|
||||
1,
|
||||
h.getId().intValue(),
|
||||
h.getGoodId().intValue(),
|
||||
goodRepository.findById(h.getGoodId()).get().getMRId().longValue(),
|
||||
null,
|
||||
h.getX(),
|
||||
h.getY(),
|
||||
"",
|
||||
"",
|
||||
h.getFrame()
|
||||
))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
public void addHouseLocation(HouseLocation house) {
|
||||
|
@ -7,6 +7,8 @@ import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@NoArgsConstructor
|
||||
public class MAService implements OutputObjectCallback {
|
||||
@ -18,4 +20,8 @@ public class MAService implements OutputObjectCallback {
|
||||
public void onOutputObjectReady(Object o) {
|
||||
this.repository.save((MagicAbility) o);
|
||||
}
|
||||
|
||||
public List<MagicAbility> getAll() {
|
||||
return this.repository.findAll();
|
||||
}
|
||||
}
|
||||
|
@ -28,4 +28,8 @@ public class MRTService implements OutputObjectCallback {
|
||||
public List<MediaResourcePath> getAll() {
|
||||
return this.repository.findAll();
|
||||
}
|
||||
|
||||
public MediaResourcePath findById(Long id) {
|
||||
return this.repository.findById(id).get();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Service
|
||||
@ -24,4 +25,8 @@ public class TRService implements OutputObjectCallback {
|
||||
public List<TextResource> getAll() {
|
||||
return this.repository.findAll();
|
||||
}
|
||||
|
||||
public Optional<TextResource> findById(Long id) {
|
||||
return this.repository.findById(id);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.alterdekim.game.service;
|
||||
import com.alterdekim.game.component.game.*;
|
||||
import com.alterdekim.game.component.game.avatar.*;
|
||||
import com.alterdekim.game.component.game.friends.UserFriend;
|
||||
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
|
||||
import com.alterdekim.game.component.game.inventory.Inventory;
|
||||
import com.alterdekim.game.component.game.inventory.InventoryList;
|
||||
import com.alterdekim.game.component.game.inventory.InventoryTab;
|
||||
@ -11,6 +12,7 @@ import com.alterdekim.game.component.game.response.init.UserInfo;
|
||||
import com.alterdekim.game.component.game.response.init.UserInitInfo;
|
||||
import com.alterdekim.game.component.game.response.init.UserPhone;
|
||||
import com.alterdekim.game.entity.*;
|
||||
import com.alterdekim.game.repository.HouseInventoryRepository;
|
||||
import com.alterdekim.game.repository.RoleRepository;
|
||||
import com.alterdekim.game.repository.UserPropertyRepository;
|
||||
import com.alterdekim.game.repository.UserRepository;
|
||||
@ -53,6 +55,9 @@ public class UserService {
|
||||
@Autowired
|
||||
private IncompatibleService incompatibleService;
|
||||
|
||||
@Autowired
|
||||
private HouseInventoryRepository houseInventoryRepository;
|
||||
|
||||
|
||||
public User findByUsername(String username) {
|
||||
return userRepository.findByUsername(username);
|
||||
@ -357,5 +362,8 @@ public class UserService {
|
||||
if( !this.inventoryService.isSpecificItemExists(userId, type, goodId) ) {
|
||||
this.inventoryService.addGoodToInventory(new AvatarInventory(userRepository.getReferenceById(userId), goodId, false, type));
|
||||
}
|
||||
if( type == AvatarInventoryType.HouseFurniture || type == AvatarInventoryType.HouseFurnitureWall ) {
|
||||
houseInventoryRepository.save(new HouseInventory(userRepository.getReferenceById(userId), goodId, -1L, 0.0, 0.0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
src/main/resources/_js/goods.js
Normal file
35
src/main/resources/_js/goods.js
Normal file
@ -0,0 +1,35 @@
|
||||
function initGoodTable(tag, data) {
|
||||
if( data.length <= 0 ) return;
|
||||
let keys = Object.keys(data[0]);
|
||||
let header = "";
|
||||
for( let i = 0; i < keys.length; i++ ) {
|
||||
header += "<th>" + keys[i] + "</th>";
|
||||
}
|
||||
$($(tag).children("thead")[0]).html("<tr>"+header+"</tr>");
|
||||
for( let i = 0; i < data.length; i++ ) {
|
||||
header = "";
|
||||
let row_id = data[i]["id"];
|
||||
for( let u = 0; u < keys.length; u++ ) {
|
||||
if( keys[u] == "url" ) {
|
||||
header += "<td><img class=\"good-img\" src=\"/"+data[i][keys[u]]+"\"></td>";
|
||||
} else {
|
||||
header += "<td>" + data[i][keys[u]] + "</td>";
|
||||
}
|
||||
}
|
||||
let tabName = tag.substring(1);
|
||||
$($(tag).children("tbody")[0]).append("<tr data-rownum=\""+row_id+"\" data-table=\""+tabName[0].toUpperCase()+tabName.substring(1)+"\">"+header+"</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
function getUserGoods() {
|
||||
$.get( "/api/get_goods", function( data ) {
|
||||
initGoodTable("#goods", data);
|
||||
set_loading("#goods", false);
|
||||
});
|
||||
}
|
||||
|
||||
function set_loading(obj, state) {
|
||||
$(obj).attr("aria-busy", state);
|
||||
}
|
||||
|
||||
getUserGoods();
|
35
src/main/resources/_js/inventory.js
Normal file
35
src/main/resources/_js/inventory.js
Normal file
@ -0,0 +1,35 @@
|
||||
function initGoodTable(tag, data) {
|
||||
if( data.length <= 0 ) return;
|
||||
let keys = Object.keys(data[0]);
|
||||
let header = "";
|
||||
for( let i = 0; i < keys.length; i++ ) {
|
||||
header += "<th>" + keys[i] + "</th>";
|
||||
}
|
||||
$($(tag).children("thead")[0]).html("<tr>"+header+"</tr>");
|
||||
for( let i = 0; i < data.length; i++ ) {
|
||||
header = "";
|
||||
let row_id = data[i]["id"];
|
||||
for( let u = 0; u < keys.length; u++ ) {
|
||||
if( keys[u] == "url" ) {
|
||||
header += "<td><img class=\"good-img\" src=\"/"+data[i][keys[u]]+"\"></td>";
|
||||
} else {
|
||||
header += "<td>" + data[i][keys[u]] + "</td>";
|
||||
}
|
||||
}
|
||||
let tabName = tag.substring(1);
|
||||
$($(tag).children("tbody")[0]).append("<tr data-rownum=\""+row_id+"\" data-table=\""+tabName[0].toUpperCase()+tabName.substring(1)+"\">"+header+"</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
function getUserGoods() {
|
||||
$.get( "/api/get_avatar_inventory?id="+$("#user_init_info").attr("data-id"), function( data ) {
|
||||
initGoodTable("#inventory", data);
|
||||
set_loading("#inventory", false);
|
||||
});
|
||||
}
|
||||
|
||||
function set_loading(obj, state) {
|
||||
$(obj).attr("aria-busy", state);
|
||||
}
|
||||
|
||||
getUserGoods();
|
@ -1,6 +1,7 @@
|
||||
const roleFlags = [
|
||||
"NONE",
|
||||
"MEMBER",
|
||||
"BOSS",
|
||||
"SA",
|
||||
"MODERATOR",
|
||||
"ADMINISTRATOR",
|
||||
|
@ -18,3 +18,8 @@ td > img {
|
||||
height: 28px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.good-img {
|
||||
width: 125px;
|
||||
height: 100px;
|
||||
}
|
@ -7,13 +7,9 @@
|
||||
<li><a href="/panel?section=Games">Games</a></li>
|
||||
<li><a href="/panel?section=Preloaders">Preloaders</a></li>
|
||||
<li><a href="/panel?section=Users">Users</a></li>
|
||||
<li><a href="/panel?section=Banlist">Banlist</a></li>
|
||||
<li><a href="/panel?section=Cache">Cache</a></li>
|
||||
<li><a href="/panel?section=Goods">Goods</a></li>
|
||||
<li><a href="/goods">Goods</a></li>
|
||||
<li><a href="/panel?section=Items">Items list</a></li>
|
||||
<li><a href="/panel?section=Actions">Actions</a></li>
|
||||
<li><a href="/panel?section=Support">Support</a></li>
|
||||
<li><a href="/panel?section=Settings">Settings</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
20
src/main/resources/templates/goods.html
Normal file
20
src/main/resources/templates/goods.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<th:block th:insert="~{fragments/head}"></th:block>
|
||||
</head>
|
||||
<body>
|
||||
<th:block th:insert="~{fragments/header}"></th:block>
|
||||
<main class="container grid" style="grid-template-columns: 1fr 6fr;">
|
||||
<th:block th:insert="~{fragments/aside}"></th:block>
|
||||
<div class="container-fluid">
|
||||
<h2>Goods with names</h2>
|
||||
<table id="goods" aria-busy="true">
|
||||
<thead></thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
<script type="text/javascript" src="/file/_js/goods.js"></script>
|
||||
</html>
|
31
src/main/resources/templates/panel_inventory.html
Normal file
31
src/main/resources/templates/panel_inventory.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<th:block th:insert="~{fragments/head}"></th:block>
|
||||
</head>
|
||||
<body>
|
||||
<th:block th:insert="~{fragments/header}"></th:block>
|
||||
<main class="container grid" style="grid-template-columns: 1fr 6fr;">
|
||||
<th:block th:insert="~{fragments/aside}"></th:block>
|
||||
<div class="container-fluid">
|
||||
<h2 id="user_init_info" th:data-id="${user_id}" th:text="${user_name}"></h2>
|
||||
<form method="POST" action="/panel_inventory">
|
||||
<fieldset role="group">
|
||||
<input type="hidden" name="id" th:value="${user_id}">
|
||||
<input
|
||||
type="number"
|
||||
name="good_id"
|
||||
placeholder="Enter good id"
|
||||
/>
|
||||
<input type="submit" value="Add to inventory" />
|
||||
</fieldset>
|
||||
</form>
|
||||
<table id="inventory" aria-busy="true">
|
||||
<thead></thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
<script type="text/javascript" src="/file/_js/inventory.js"></script>
|
||||
</html>
|
@ -9,6 +9,7 @@
|
||||
<th:block th:insert="~{fragments/aside}"></th:block>
|
||||
<div class="container-fluid">
|
||||
<h2 id="user_init_info" th:data-id="${user_id}" th:text="${user_name}"></h2>
|
||||
<a th:href="${inventory_link}"><button class="primary">Inventory</button></a>
|
||||
<table id="properties" aria-busy="true">
|
||||
<thead></thead>
|
||||
<tbody></tbody>
|
||||
|
Loading…
x
Reference in New Issue
Block a user