package main

import (
	"../gameapi"
	"../log"
	"./executor"
	"go.uber.org/zap"
	"strconv"
)
//fg适用于强制关端还有未完的牌局

type FG_param struct {
	Guid string `json:"guid"`
	GameId string `json:"gameId"`
}

type Executor_FG struct {
	cmd string
}

func (self *Executor_FG) Execute(p interface{}) int32 {
		guid_uint64   := uint64(p.(map[string]interface{})["guid"].(float64))
		gameId_int64  := int64(p.(map[string]interface{})["gameId"].(float64))

		guid_str := strconv.FormatUint(guid_uint64,10)
		gameId_str := strconv.FormatInt(gameId_int64,10)

		with_money, ok := gameapi.FG_withdraw(guid_str)
		if ok {
			newBanlance := gameapi.SettlementAndNtfToNats("FG",guid_uint64, gameId_int64, with_money)
			log.Debug("Executor_FG 任务执行成功",zap.String("guid", guid_str),zap.String("gameId", gameId_str))
			TaskPool.RemoveTasks(int64(guid_uint64))
			notifyClientByLobby(guid_uint64, newBanlance)
			gameapi.CleanReconnectInfo("FG", guid_uint64)
			return  TASK_SUCCESS
		}else{
			log.Debug("Executor_FG 任务执行失败",zap.String("guid", guid_str),zap.String("gameId", gameId_str))
			return  TASK_FAILED
		}
}

func NewExecutor_FG(cmd string) executor.IExecutor {
	return &Executor_FG{cmd:cmd}
}

func register_FG() {
	executor.RegisterFunc("Executor_FG", NewExecutor_FG("withdraw"))
}

