Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
7b591a2d
Commit
7b591a2d
authored
May 02, 2022
by
xtaodada
Committed by
Melledy
May 02, 2022
Browse files
implement shopMail giftPackage function
Co-authored-by:
Kinesis
<
CCasusensa@users.noreply.github.com
>
parent
73fc9fe4
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/GameData.java
View file @
7b591a2d
...
@@ -62,6 +62,7 @@ public class GameData {
...
@@ -62,6 +62,7 @@ public class GameData {
private
static
final
Int2ObjectMap
<
FetterData
>
fetterDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterData
>
fetterDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterCharacterCardData
>
fetterCharacterCardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
FetterCharacterCardData
>
fetterCharacterCardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardData
>
rewardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardData
>
rewardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardBoxData
>
rewardBoxDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DailyDungeonData
>
dailyDungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DailyDungeonData
>
dailyDungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DungeonData
>
dungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DungeonData
>
dungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
...
@@ -263,6 +264,10 @@ public class GameData {
...
@@ -263,6 +264,10 @@ public class GameData {
return
rewardDataMap
;
return
rewardDataMap
;
}
}
public
static
Int2ObjectMap
<
RewardBoxData
>
getRewardBoxDataMap
()
{
return
rewardBoxDataMap
;
}
public
static
Map
<
Integer
,
List
<
Integer
>>
getFetterDataEntries
()
{
public
static
Map
<
Integer
,
List
<
Integer
>>
getFetterDataEntries
()
{
if
(
fetters
.
isEmpty
())
{
if
(
fetters
.
isEmpty
())
{
fetterDataMap
.
forEach
((
k
,
v
)
->
{
fetterDataMap
.
forEach
((
k
,
v
)
->
{
...
...
src/main/java/emu/grasscutter/data/common/RewardBoxItemData.java
0 → 100644
View file @
7b591a2d
package
emu.grasscutter.data.common
;
public
class
RewardBoxItemData
{
private
int
Id
;
private
String
Count
;
public
int
getItemId
()
{
return
Id
;
}
public
void
setItemId
(
int
itemId
)
{
Id
=
itemId
;
}
public
String
getItemCount
()
{
return
Count
;
}
public
void
setItemCount
(
String
itemCount
)
{
Count
=
itemCount
;
}
}
src/main/java/emu/grasscutter/data/def/RewardBoxData.java
0 → 100644
View file @
7b591a2d
package
emu.grasscutter.data.def
;
import
java.util.List
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.data.common.RewardBoxItemData
;
@ResourceType
(
name
=
"RewardPreviewExcelConfigData.json"
)
public
class
RewardBoxData
extends
GameResource
{
public
int
Id
;
public
List
<
RewardBoxItemData
>
PreviewItems
;
@Override
public
int
getId
()
{
return
Id
;
}
public
List
<
RewardBoxItemData
>
getRewardBoxItemList
()
{
return
PreviewItems
;
}
@Override
public
void
onLoad
()
{
}
}
src/main/java/emu/grasscutter/data/def/ShopGoodsData.java
View file @
7b591a2d
...
@@ -30,6 +30,7 @@ public class ShopGoodsData extends GameResource {
...
@@ -30,6 +30,7 @@ public class ShopGoodsData extends GameResource {
private
transient
ShopInfo
.
ShopRefreshType
RefreshTypeEnum
;
private
transient
ShopInfo
.
ShopRefreshType
RefreshTypeEnum
;
private
int
RefreshParam
;
private
int
RefreshParam
;
private
int
ShowId
;
@Override
@Override
public
void
onLoad
()
{
public
void
onLoad
()
{
...
@@ -105,4 +106,8 @@ public class ShopGoodsData extends GameResource {
...
@@ -105,4 +106,8 @@ public class ShopGoodsData extends GameResource {
public
int
getRefreshParam
()
{
public
int
getRefreshParam
()
{
return
RefreshParam
;
return
RefreshParam
;
}
}
public
int
getShowId
()
{
return
ShowId
;
}
}
}
src/main/java/emu/grasscutter/game/inventory/GameItem.java
View file @
7b591a2d
...
@@ -58,6 +58,9 @@ public class GameItem {
...
@@ -58,6 +58,9 @@ public class GameItem {
// Relic
// Relic
private
int
mainPropId
;
private
int
mainPropId
;
private
List
<
Integer
>
appendPropIdList
;
private
List
<
Integer
>
appendPropIdList
;
// shopMailBox
private
int
rewardBoxId
;
private
int
equipCharacter
;
private
int
equipCharacter
;
@Transient
private
int
weaponEntityId
;
@Transient
private
int
weaponEntityId
;
...
@@ -90,7 +93,7 @@ public class GameItem {
...
@@ -90,7 +93,7 @@ public class GameItem {
// Equip data
// Equip data
if
(
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
{
if
(
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
{
this
.
level
=
this
.
count
>
1
?
this
.
count
:
1
;
this
.
level
=
Math
.
max
(
this
.
count
,
1
)
;
this
.
affixes
=
new
ArrayList
<>(
2
);
this
.
affixes
=
new
ArrayList
<>(
2
);
if
(
getItemData
().
getSkillAffix
()
!=
null
)
{
if
(
getItemData
().
getSkillAffix
()
!=
null
)
{
for
(
int
skillAffix
:
getItemData
().
getSkillAffix
())
{
for
(
int
skillAffix
:
getItemData
().
getSkillAffix
())
{
...
@@ -248,6 +251,14 @@ public class GameItem {
...
@@ -248,6 +251,14 @@ public class GameItem {
this
.
mainPropId
=
mainPropId
;
this
.
mainPropId
=
mainPropId
;
}
}
public
int
getRewardBoxId
()
{
return
rewardBoxId
;
}
public
void
setRewardBoxId
(
int
rewardBoxId
)
{
this
.
rewardBoxId
=
rewardBoxId
;
}
public
List
<
Integer
>
getAppendPropIdList
()
{
public
List
<
Integer
>
getAppendPropIdList
()
{
return
appendPropIdList
;
return
appendPropIdList
;
}
}
...
...
src/main/java/emu/grasscutter/game/managers/InventoryManager.java
View file @
7b591a2d
...
@@ -7,11 +7,13 @@ import java.util.stream.Collectors;
...
@@ -7,11 +7,13 @@ import java.util.stream.Collectors;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.common.RewardBoxItemData
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry
;
import
emu.grasscutter.data.custom.OpenConfigEntry.SkillPointModifier
;
import
emu.grasscutter.data.custom.OpenConfigEntry.SkillPointModifier
;
import
emu.grasscutter.data.def.AvatarPromoteData
;
import
emu.grasscutter.data.def.AvatarPromoteData
;
import
emu.grasscutter.data.def.AvatarSkillData
;
import
emu.grasscutter.data.def.AvatarSkillData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData
;
import
emu.grasscutter.data.def.RewardBoxData
;
import
emu.grasscutter.data.def.WeaponPromoteData
;
import
emu.grasscutter.data.def.WeaponPromoteData
;
import
emu.grasscutter.data.def.AvatarSkillDepotData.InherentProudSkillOpens
;
import
emu.grasscutter.data.def.AvatarSkillDepotData.InherentProudSkillOpens
;
import
emu.grasscutter.data.def.AvatarTalentData
;
import
emu.grasscutter.data.def.AvatarTalentData
;
...
@@ -21,6 +23,7 @@ import emu.grasscutter.game.inventory.GameItem;
...
@@ -21,6 +23,7 @@ import emu.grasscutter.game.inventory.GameItem;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.inventory.ItemType
;
import
emu.grasscutter.game.inventory.MaterialType
;
import
emu.grasscutter.game.inventory.MaterialType
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
import
emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam
;
import
emu.grasscutter.net.proto.MaterialInfoOuterClass.MaterialInfo
;
import
emu.grasscutter.net.proto.MaterialInfoOuterClass.MaterialInfo
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
...
@@ -897,6 +900,26 @@ public class InventoryManager {
...
@@ -897,6 +900,26 @@ public class InventoryManager {
player
.
sendPacket
(
new
PacketDestroyMaterialRsp
(
returnMaterialMap
));
player
.
sendPacket
(
new
PacketDestroyMaterialRsp
(
returnMaterialMap
));
}
}
private
boolean
handleRewardBox
(
Player
player
,
GameItem
useItem
)
{
List
<
RewardBoxData
>
rewardBoxDataList
=
GameData
.
getRewardBoxDataMap
().
values
().
stream
().
filter
(
x
->
x
.
getId
()
==
useItem
.
getRewardBoxId
()).
collect
(
Collectors
.
toList
());
if
(
rewardBoxDataList
.
isEmpty
())
{
return
false
;
}
List
<
GameItem
>
rewardItemList
=
new
ArrayList
<>();
for
(
RewardBoxItemData
itemData
:
rewardBoxDataList
.
get
(
0
).
getRewardBoxItemList
())
{
if
(
itemData
.
getItemId
()
==
0
)
{
continue
;
}
String
[]
split
=
itemData
.
getItemCount
().
split
(
";"
);
int
itemCount
=
Integer
.
parseInt
(
split
[(
int
)
(
Math
.
random
()*
split
.
length
)]);
rewardItemList
.
add
(
new
GameItem
(
itemData
.
getItemId
(),
itemCount
));
}
if
(!
rewardItemList
.
isEmpty
())
{
player
.
getInventory
().
addItems
(
rewardItemList
,
ActionReason
.
Shop
);
}
return
true
;
}
public
GameItem
useItem
(
Player
player
,
long
targetGuid
,
long
itemGuid
,
int
count
)
{
public
GameItem
useItem
(
Player
player
,
long
targetGuid
,
long
itemGuid
,
int
count
)
{
Avatar
target
=
player
.
getAvatars
().
getAvatarByGuid
(
targetGuid
);
Avatar
target
=
player
.
getAvatars
().
getAvatarByGuid
(
targetGuid
);
GameItem
useItem
=
player
.
getInventory
().
getItemByGuid
(
itemGuid
);
GameItem
useItem
=
player
.
getInventory
().
getItemByGuid
(
itemGuid
);
...
@@ -918,6 +941,11 @@ public class InventoryManager {
...
@@ -918,6 +941,11 @@ public class InventoryManager {
used
=
player
.
getTeamManager
().
reviveAvatar
(
target
)
?
1
:
0
;
used
=
player
.
getTeamManager
().
reviveAvatar
(
target
)
?
1
:
0
;
}
}
break
;
break
;
case
MATERIAL_CHEST:
if
(
useItem
.
getRewardBoxId
()
>
0
)
{
used
=
handleRewardBox
(
player
,
useItem
)
?
1
:
0
;
}
break
;
default
:
default
:
break
;
break
;
}
}
...
...
src/main/java/emu/grasscutter/game/shop/ShopInfo.java
View file @
7b591a2d
...
@@ -13,6 +13,7 @@ public class ShopInfo {
...
@@ -13,6 +13,7 @@ public class ShopInfo {
private
List
<
ItemParamData
>
costItemList
;
private
List
<
ItemParamData
>
costItemList
;
private
int
boughtNum
=
0
;
private
int
boughtNum
=
0
;
private
int
buyLimit
=
0
;
private
int
buyLimit
=
0
;
private
int
showId
=
0
;
private
int
beginTime
=
0
;
private
int
beginTime
=
0
;
private
int
endTime
=
1924992000
;
private
int
endTime
=
1924992000
;
private
int
minLevel
=
0
;
private
int
minLevel
=
0
;
...
@@ -51,6 +52,7 @@ public class ShopInfo {
...
@@ -51,6 +52,7 @@ public class ShopInfo {
this
.
mcoin
=
sgd
.
getCostMcoin
();
this
.
mcoin
=
sgd
.
getCostMcoin
();
this
.
hcoin
=
sgd
.
getCostHcoin
();
this
.
hcoin
=
sgd
.
getCostHcoin
();
this
.
buyLimit
=
sgd
.
getBuyLimit
();
this
.
buyLimit
=
sgd
.
getBuyLimit
();
this
.
showId
=
sgd
.
getShowId
();
this
.
minLevel
=
sgd
.
getMinPlayerLevel
();
this
.
minLevel
=
sgd
.
getMinPlayerLevel
();
this
.
maxLevel
=
sgd
.
getMaxPlayerLevel
();
this
.
maxLevel
=
sgd
.
getMaxPlayerLevel
();
...
@@ -180,6 +182,14 @@ public class ShopInfo {
...
@@ -180,6 +182,14 @@ public class ShopInfo {
this
.
maxLevel
=
maxLevel
;
this
.
maxLevel
=
maxLevel
;
}
}
public
int
getShowId
()
{
return
showId
;
}
public
void
setShowId
(
int
showId
)
{
this
.
showId
=
showId
;
}
public
ShopRefreshType
getShopRefreshType
()
{
public
ShopRefreshType
getShopRefreshType
()
{
if
(
refreshType
==
null
)
if
(
refreshType
==
null
)
return
ShopRefreshType
.
NONE
;
return
ShopRefreshType
.
NONE
;
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java
View file @
7b591a2d
...
@@ -4,7 +4,6 @@ import emu.grasscutter.data.GameData;
...
@@ -4,7 +4,6 @@ import emu.grasscutter.data.GameData;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.shop.ShopInfo
;
import
emu.grasscutter.game.shop.ShopInfo
;
import
emu.grasscutter.game.shop.ShopLimit
;
import
emu.grasscutter.game.shop.ShopLimit
;
import
emu.grasscutter.game.shop.ShopManager
;
import
emu.grasscutter.game.shop.ShopManager
;
...
@@ -19,7 +18,6 @@ import emu.grasscutter.server.packet.send.PacketBuyGoodsRsp;
...
@@ -19,7 +18,6 @@ import emu.grasscutter.server.packet.send.PacketBuyGoodsRsp;
import
emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -92,6 +90,9 @@ public class HandlerBuyGoodsReq extends PacketHandler {
...
@@ -92,6 +90,9 @@ public class HandlerBuyGoodsReq extends PacketHandler {
session
.
getPlayer
().
addShopLimit
(
sg
.
getGoodsId
(),
buyGoodsReq
.
getBoughtNum
(),
ShopManager
.
getShopNextRefreshTime
(
sg
));
session
.
getPlayer
().
addShopLimit
(
sg
.
getGoodsId
(),
buyGoodsReq
.
getBoughtNum
(),
ShopManager
.
getShopNextRefreshTime
(
sg
));
GameItem
item
=
new
GameItem
(
GameData
.
getItemDataMap
().
get
(
sg
.
getGoodsItem
().
getId
()));
GameItem
item
=
new
GameItem
(
GameData
.
getItemDataMap
().
get
(
sg
.
getGoodsItem
().
getId
()));
item
.
setCount
(
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getGoodsItem
().
getCount
());
item
.
setCount
(
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getGoodsItem
().
getCount
());
if
(
sg
.
getShowId
()
>
0
)
{
item
.
setRewardBoxId
(
sg
.
getShowId
());
}
session
.
getPlayer
().
getInventory
().
addItem
(
item
,
ActionReason
.
Shop
,
true
);
// fix: not notify when got virtual item from shop
session
.
getPlayer
().
getInventory
().
addItem
(
item
,
ActionReason
.
Shop
,
true
);
// fix: not notify when got virtual item from shop
session
.
send
(
new
PacketBuyGoodsRsp
(
buyGoodsReq
.
getShopType
(),
session
.
getPlayer
().
getGoodsLimit
(
sg
.
getGoodsId
()).
getHasBoughtInPeriod
(),
buyGoodsReq
.
getGoodsListList
().
stream
().
filter
(
x
->
x
.
getGoodsId
()
==
goodsId
).
findFirst
().
get
()));
session
.
send
(
new
PacketBuyGoodsRsp
(
buyGoodsReq
.
getShopType
(),
session
.
getPlayer
().
getGoodsLimit
(
sg
.
getGoodsId
()).
getHasBoughtInPeriod
(),
buyGoodsReq
.
getGoodsListList
().
stream
().
filter
(
x
->
x
.
getGoodsId
()
==
goodsId
).
findFirst
().
get
()));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment