【猫草大作战】-修改领奖逻辑
This commit is contained in:
parent
b48aeea1d8
commit
e4e1b93a9a
@ -112,6 +112,21 @@ func GetProgressReward(Id int, Rewards []int, Progress int) ([]*item.Item, []int
|
|||||||
return Items, Ids
|
return Items, Ids
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetProgressNum(Id int) int {
|
||||||
|
TemplateId := GetTemplateId(Id)
|
||||||
|
data, err := gamedata.GetData(CATNIP_GAME_CFG_NAME)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
Num := 0
|
||||||
|
for _, v := range data {
|
||||||
|
if gamedata.GetIntValue(v, "Template") == TemplateId {
|
||||||
|
Num++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Num
|
||||||
|
}
|
||||||
|
|
||||||
func GetItemCost(Id, Mul int) []*item.Item {
|
func GetItemCost(Id, Mul int) []*item.Item {
|
||||||
data, err := gamedata.GetDataByIntKey(CATNIP_TEMPLATE_CFG_NAME, Id)
|
data, err := gamedata.GetDataByIntKey(CATNIP_TEMPLATE_CFG_NAME, Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -189,7 +189,11 @@ func (c *CatnipMod) Reward(Id int) ([]*item.Item, *CatnipGame, error) {
|
|||||||
return nil, nil, fmt.Errorf("game with Progress %d does not exist", Id)
|
return nil, nil, fmt.Errorf("game with Progress %d does not exist", Id)
|
||||||
}
|
}
|
||||||
Items, Ids := catnipCfg.GetProgressReward(c.Id, GameInfo.Reward, GameInfo.Progress)
|
Items, Ids := catnipCfg.GetProgressReward(c.Id, GameInfo.Reward, GameInfo.Progress)
|
||||||
|
ProgressNum := catnipCfg.GetProgressNum(c.Id)
|
||||||
GameInfo.Reward = append(GameInfo.Reward, Ids...)
|
GameInfo.Reward = append(GameInfo.Reward, Ids...)
|
||||||
|
if len(GameInfo.Reward) == ProgressNum {
|
||||||
|
GameInfo.Status = GAME_STATUS_COMPLETED
|
||||||
|
}
|
||||||
if Items == nil {
|
if Items == nil {
|
||||||
return nil, nil, fmt.Errorf("no reward found for progress %d in game ID %d", GameInfo.Progress, Id)
|
return nil, nil, fmt.Errorf("no reward found for progress %d in game ID %d", GameInfo.Progress, Id)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user