當前位置: 首頁>>代碼示例>>Golang>>正文


Golang UIState.GameID方法代碼示例

本文整理匯總了Golang中hearts/img/uistate.UIState.GameID方法的典型用法代碼示例。如果您正苦於以下問題:Golang UIState.GameID方法的具體用法?Golang UIState.GameID怎麽用?Golang UIState.GameID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在hearts/img/uistate.UIState的用法示例。


在下文中一共展示了UIState.GameID方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CreateLogSyncgroup

// Creates a new gamelog syncgroup
func CreateLogSyncgroup(u *uistate.UIState) (string, string) {
	fmt.Println("Creating Log Syncgroup")
	u.IsOwner = true
	// Generate random gameID information to advertise this game
	gameID := rand.Intn(1000000)
	u.GameID = gameID
	gameMap := make(map[string]interface{})
	gameMap["type"] = "Hearts"
	gameMap["playerNumber"] = 0
	gameMap["gameID"] = gameID
	gameMap["ownerID"] = util.UserID
	value, err := json.Marshal(gameMap)
	if err != nil {
		fmt.Println("WE HAVE A HUGE PROBLEM:", err)
	}
	// Create gamelog syncgroup
	logSGName := fmt.Sprintf("%s/croupier/%s/%%%%sync/gaming-%d", util.MountPoint, util.SBName, gameID)
	allAccess := access.AccessList{In: []security.BlessingPattern{"..."}}
	permissions := access.Permissions{
		"Admin":   allAccess,
		"Write":   allAccess,
		"Read":    allAccess,
		"Resolve": allAccess,
		"Debug":   allAccess,
	}
	logPref := wire.TableRow{util.LogName, fmt.Sprintf("%d", u.GameID)}
	logPrefs := []wire.TableRow{logPref}
	tables := []string{util.MountPoint + "/croupier"}
	logSpec := wire.SyncgroupSpec{
		Description: "croupier syncgroup",
		Perms:       permissions,
		Prefixes:    logPrefs,
		MountTables: tables,
		IsPrivate:   false,
	}
	myInfoCreator := wire.SyncgroupMemberInfo{8, true}
	app := u.Service.App(util.AppName)
	db := app.Database(util.DbName, nil)
	logSG := db.Syncgroup(logSGName)
	err = logSG.Create(u.Ctx, logSpec, myInfoCreator)
	if err != nil {
		fmt.Println("SYNCGROUP CREATE ERROR: ", err)
		fmt.Println("JOINING INSTEAD...")
		_, err2 := logSG.Join(u.Ctx, myInfoCreator)
		if err2 != nil {
			fmt.Println("SYNCGROUP JOIN ERROR: ", err2)
			return string(value), ""
		} else {
			return string(value), logSGName
		}
	} else {
		fmt.Println("Syncgroup created")
		if logSGName != u.LogSG {
			ResetGame(logSGName, true, u)
		}
		return string(value), logSGName
	}
}
開發者ID:vanadium,項目名稱:croupier,代碼行數:59,代碼來源:server.go

示例2: ResetGame

func ResetGame(logName string, creator bool, u *uistate.UIState) {
	u.M.Lock()
	defer u.M.Unlock()
	go sendTrueIfExists(u.GameChan)
	u.PlayerData = make(map[int]int)
	u.CurPlayerIndex = -1
	u.LogSG = logName
	writeLogAddr(logName, creator)
	u.CurTable.NewGame()
	tmp := strings.Split(logName, "-")
	gameID, _ := strconv.Atoi(tmp[len(tmp)-1])
	u.GameID = gameID
	u.GameChan = make(chan bool)
	go UpdateGame(u.GameChan, u)
}
開發者ID:vanadium,項目名稱:croupier,代碼行數:15,代碼來源:server.go


注:本文中的hearts/img/uistate.UIState.GameID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。