MiniGames (singleplayer) added
This commit is contained in:
parent
cd5c4779c7
commit
7440d33ddd
@ -57,6 +57,9 @@ public class GameServer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MiniGameService miniGameService;
|
||||||
|
|
||||||
private final Map<Integer, Player> players;
|
private final Map<Integer, Player> players;
|
||||||
|
|
||||||
private final ObjectMapper xmlMapper;
|
private final ObjectMapper xmlMapper;
|
||||||
@ -103,7 +106,7 @@ public class GameServer {
|
|||||||
private void setPlayerAvatarPosition(int playerId, SetPlayerAvatarPosition message) {
|
private void setPlayerAvatarPosition(int playerId, SetPlayerAvatarPosition message) {
|
||||||
if( message.getCoordinates() != null ) {
|
if( message.getCoordinates() != null ) {
|
||||||
players.get(playerId).setX(message.getCoordinates().get("x").getDouble());
|
players.get(playerId).setX(message.getCoordinates().get("x").getDouble());
|
||||||
players.get(playerId).setY(message.getCoordinates().get("y").getDouble());
|
players.get(playerId).setY(message.getCoordinates().containsKey("y") ? message.getCoordinates().get("y").getDouble() : -100);
|
||||||
}
|
}
|
||||||
this.sendInPlayersLocation(playerId, CommandType.SetUserAvatarPosition,
|
this.sendInPlayersLocation(playerId, CommandType.SetUserAvatarPosition,
|
||||||
new SetPlayerPosition(
|
new SetPlayerPosition(
|
||||||
@ -239,7 +242,7 @@ public class GameServer {
|
|||||||
phoneMessageService.markAsRead(messageId);
|
phoneMessageService.markAsRead(messageId);
|
||||||
}
|
}
|
||||||
case DeletePhoneMessage -> {
|
case DeletePhoneMessage -> {
|
||||||
Long messageId1 = message.getArguments().get(0).getLong();
|
long messageId1 = message.getArguments().get(0).getLong();
|
||||||
phoneMessageService.removeById(messageId1);
|
phoneMessageService.removeById(messageId1);
|
||||||
}
|
}
|
||||||
case CardMessage -> {
|
case CardMessage -> {
|
||||||
@ -266,9 +269,23 @@ public class GameServer {
|
|||||||
}
|
}
|
||||||
case BuyBatch -> buySomething(playerId, message.getArguments().get(0), message);
|
case BuyBatch -> buySomething(playerId, message.getArguments().get(0), message);
|
||||||
case LockHouse -> lockSomething(playerId, message.getArguments().get(0).getInt(), message.getArguments().get(1).getBoolean(), message);
|
case LockHouse -> lockSomething(playerId, message.getArguments().get(0).getInt(), message.getArguments().get(1).getBoolean(), message);
|
||||||
|
case GetGame -> getGame(playerId, message.getArguments().get(0).getLong(), message.getTransactionId());
|
||||||
|
case GameScore -> processGameScore(playerId, message.getTransactionId(), message.getArguments().get(1).getInt());
|
||||||
|
case SendGameClose, GameStatistics -> {
|
||||||
|
this.sendResult(playerId, message.getTransactionId(), "0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processGameScore(int playerId, double transactionId, int amount) {
|
||||||
|
this.addUsualTickets(playerId, amount);
|
||||||
|
this.sendResult(playerId, transactionId, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getGame(int playerId, long gameId, double transactionId) throws JsonProcessingException {
|
||||||
|
this.sendResult(playerId, transactionId, xmlMapper.writeValueAsString(miniGameService.findGameById(gameId).get()));
|
||||||
|
}
|
||||||
|
|
||||||
private void lockSomething(int playerId, int what2Lock, Boolean state, UserMessage message) {
|
private void lockSomething(int playerId, int what2Lock, Boolean state, UserMessage message) {
|
||||||
if( what2Lock == -2 ) {
|
if( what2Lock == -2 ) {
|
||||||
this.users.pushUserProperty(playerId, PlayerProperties.IsClubLocked, state);
|
this.users.pushUserProperty(playerId, PlayerProperties.IsClubLocked, state);
|
||||||
@ -312,6 +329,13 @@ public class GameServer {
|
|||||||
this.sendResult(playerId, message.getTransactionId(), new BuyGoodResultGood(new BuyGoodResultGood.BuyGoodBody(false, new ArrayList<>())));
|
this.sendResult(playerId, message.getTransactionId(), new BuyGoodResultGood(new BuyGoodResultGood.BuyGoodBody(false, new ArrayList<>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addUsualTickets(int userId, int amount) {
|
||||||
|
int val = this.users.getUsualTickets(userId);
|
||||||
|
val += amount;
|
||||||
|
this.users.setUsualTickets(userId, val);
|
||||||
|
this.call(userId, CommandType.UpdateTickets, new UpdateTickets(val, this.users.getMagicTickets(userId)));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean subtractUsualTickets(int userId, int amount) {
|
private boolean subtractUsualTickets(int userId, int amount) {
|
||||||
int val = this.users.getUsualTickets(userId);
|
int val = this.users.getUsualTickets(userId);
|
||||||
if ( val >= amount ) {
|
if ( val >= amount ) {
|
||||||
|
@ -137,6 +137,9 @@ public class StartUpListener {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PromotionBannerService promotionBannerService;
|
private PromotionBannerService promotionBannerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MiniGameService miniGameService;
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
this.startTime = System.currentTimeMillis();
|
this.startTime = System.currentTimeMillis();
|
||||||
@ -184,12 +187,34 @@ public class StartUpListener {
|
|||||||
pushLocations();
|
pushLocations();
|
||||||
pushLocationObjects();
|
pushLocationObjects();
|
||||||
|
|
||||||
|
pushMiniGames();
|
||||||
|
|
||||||
pushHouseLocations();
|
pushHouseLocations();
|
||||||
|
|
||||||
pushPhoneSkins();
|
pushPhoneSkins();
|
||||||
log.info("Initialization complete");
|
log.info("Initialization complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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", ""));
|
||||||
|
}
|
||||||
|
|
||||||
private void pushPhoneSkins() {
|
private void pushPhoneSkins() {
|
||||||
phoneIconService.findAll()
|
phoneIconService.findAll()
|
||||||
.stream()
|
.stream()
|
||||||
@ -487,7 +512,6 @@ public class StartUpListener {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: implement other stuff from base.swf
|
|
||||||
private void processBase(String swf) throws IOException {
|
private void processBase(String swf) throws IOException {
|
||||||
log.info("Processing base");
|
log.info("Processing base");
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ public enum UserCommandType {
|
|||||||
DeleteCardMessage("_MCD"),
|
DeleteCardMessage("_MCD"),
|
||||||
LockHouse("_LL"),
|
LockHouse("_LL"),
|
||||||
BuyBatch("_BGB"),
|
BuyBatch("_BGB"),
|
||||||
|
GetGame("_GG"),
|
||||||
|
GameScore("_GS"),
|
||||||
|
SendGameClose("_GC"),
|
||||||
|
GameStatistics("_GT"),
|
||||||
Unknown("");
|
Unknown("");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
80
src/main/java/com/alterdekim/game/entity/MiniGame.java
Normal file
80
src/main/java/com/alterdekim/game/entity/MiniGame.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package com.alterdekim.game.entity;
|
||||||
|
|
||||||
|
import com.alterdekim.flash.decompiler.mapper.FlashValue;
|
||||||
|
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 jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "minigames")
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public class MiniGame {
|
||||||
|
@Id
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "GameName")
|
||||||
|
private String gameName;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "NameTRId")
|
||||||
|
private Integer nameTRId;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "TextResourceID")
|
||||||
|
private Integer textResourceID;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
|
||||||
|
private Integer mediaResourceID;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "ScoreDivisor")
|
||||||
|
private Double scoreDivisor;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "AvatarType")
|
||||||
|
private Integer avatarType;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "IsPromptUsed")
|
||||||
|
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||||
|
private Boolean isPromptUsed;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "IsFullscreen")
|
||||||
|
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||||
|
private Boolean isFullscreen;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "IsShowPoints")
|
||||||
|
@JsonSerialize(using = NumericBooleanSerializer.class)
|
||||||
|
private Boolean isShowPoints;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "StartFullTime")
|
||||||
|
private Long startFullTime;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "StartLackTime")
|
||||||
|
private Long startLackTime;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "Options")
|
||||||
|
private String options;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "Token")
|
||||||
|
private String token;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.alterdekim.game.repository;
|
||||||
|
|
||||||
|
import com.alterdekim.game.entity.MiniGame;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface MiniGameRepository extends JpaRepository<MiniGame, Long> {
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.alterdekim.game.service;
|
||||||
|
|
||||||
|
import com.alterdekim.game.entity.MiniGame;
|
||||||
|
import com.alterdekim.game.repository.MiniGameRepository;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MiniGameService {
|
||||||
|
@Autowired
|
||||||
|
private MiniGameRepository repository;
|
||||||
|
|
||||||
|
public void save(MiniGame game) {
|
||||||
|
this.repository.save(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<MiniGame> findGameById(Long id) {
|
||||||
|
return this.repository.findById(id);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user