House update
This commit is contained in:
parent
31a02be28a
commit
17c9af6414
@ -1,6 +1,8 @@
|
||||
<center><img align="center" src="https://w0n.zip/file/5eVXOb"></center>
|
||||
|
||||
<p align="center">Feels like a distant memory</p>
|
||||
|
||||
# WhimsyWorld
|
||||
|
||||

|
||||

|
||||

|
||||
|
@ -3,6 +3,9 @@ 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;
|
||||
@ -63,6 +66,9 @@ public class GameServer {
|
||||
@Autowired
|
||||
private MiniGameService miniGameService;
|
||||
|
||||
@Autowired
|
||||
private HomeInventoryService homeInventoryService;
|
||||
|
||||
private final Map<Integer, Player> players;
|
||||
|
||||
private final ObjectMapper xmlMapper;
|
||||
@ -159,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;
|
||||
}
|
||||
@ -297,6 +304,30 @@ public class GameServer {
|
||||
//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();
|
||||
Map<String, AMFObject> additions = (Map<String, AMFObject>) info.get("Add").getRaw();
|
||||
this.homeInventoryService.addFurnitureToCurrentHome(playerId, additions);
|
||||
|
||||
Map<String, AMFObject> changes = (Map<String, AMFObject>) info.get("Changes").getRaw();
|
||||
this.homeInventoryService.addFurnitureToCurrentHome(playerId, changes);
|
||||
return;
|
||||
}
|
||||
// club
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ public enum UserCommandType {
|
||||
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;
|
||||
}
|
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;
|
||||
}
|
||||
}
|
@ -104,7 +104,9 @@ public class AMFDeserializer {
|
||||
a.clear();
|
||||
if( keyLen == 0 ) {
|
||||
endMarker = true;
|
||||
bytes.remove();
|
||||
if( !bytes.isEmpty() ) {
|
||||
bytes.remove();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
bytes.subList(0, Math.min(keyLen, bytes.size())).clear();
|
||||
|
@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
@ -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) {
|
||||
|
@ -0,0 +1,84 @@
|
||||
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 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,24 @@ 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(
|
||||
2,
|
||||
h.getId().intValue(),
|
||||
h.getGoodId().intValue(),
|
||||
goodRepository.findById(h.getGoodId()).get().getMRId().longValue(),
|
||||
null,
|
||||
h.getX(),
|
||||
h.getY(),
|
||||
"",
|
||||
""
|
||||
))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
public void addHouseLocation(HouseLocation house) {
|
||||
|
@ -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 ) {
|
||||
houseInventoryRepository.save(new HouseInventory(userRepository.getReferenceById(userId), goodId, -1L, 0.0, 0.0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user