コード例 #1
0
ファイル: sign.go プロジェクト: zhjh1209/a_game
func signProto(day int) []*protodata.RewardData {

	var result []*protodata.RewardData
	Lua, _ := lua.NewLua("conf/sign_reward.lua")

	begin := day/7 - 1
	if begin < 0 {
		begin = 0
	}
	begin = begin*7 + 1
	for i := begin; i <= begin+7; i++ {

		//Lua.L.GetGlobal("signReward")
		Lua.L.DoString(fmt.Sprintf("coin, diamond, action, generalId = signReward(%d)", i))
		coin := Lua.GetInt("coin")
		diamond := Lua.GetInt("diamond")
		action := Lua.GetInt("action")
		generalId := Lua.GetInt("generalId")

		temp := new(protodata.RewardData)
		temp.RewardCoin = proto.Int32(int32(coin))
		temp.RewardDiamond = proto.Int32(int32(diamond))
		temp.Stamina = proto.Int32(int32(action))
		if generalId > 0 {
			config := models.BaseGeneral(generalId, nil)
			temp.General = generalProto(new(models.GeneralData), config)
		}

		result = append(result, temp)
	}

	Lua.Close()
	return result
}