本文整理汇总了Golang中mule/overpower.GameDat.AutoDays方法的典型用法代码示例。如果您正苦于以下问题:Golang GameDat.AutoDays方法的具体用法?Golang GameDat.AutoDays怎么用?Golang GameDat.AutoDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mule/overpower.GameDat
的用法示例。
在下文中一共展示了GameDat.AutoDays方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: pageOPHome
func pageOPHome(w http.ResponseWriter, r *http.Request) {
h := MakeHandler(w, r)
if !h.LoggedIn {
http.Redirect(w, r, "/auth/login", http.StatusFound)
return
}
if r.URL.Path != "/overpower/home" {
http.Redirect(w, r, "/overpower/home", http.StatusFound)
return
}
var hasG bool
var g overpower.GameDat
games, err := h.M.Game().Select("owner", h.User.String())
if my, bad := Check(err, "resource failure on OP home page", "resource", "game", "owner", h.User.String()); bad {
h.HandleServerError(w, r, my)
return
}
if len(games) != 0 {
g = games[0]
hasG = true
}
var gFacs []overpower.FactionDat
var gHasF bool
if hasG {
gFacs, err = h.M.Faction().SelectWhere(h.GID(g.GID()))
if my, bad := Check(err, "resource error in homepage", "resource", "faction", "user", h.User, "gid", g.GID()); bad {
h.HandleServerError(w, r, my)
return
}
gHasF = len(gFacs) > 0
}
if r.Method == "POST" {
if DBLOCK {
h.HandleUserError(w, r, "GAME DOWN FOR DAYLY MAINT: 10-20MIN")
return
}
action := r.FormValue("action")
var errS, errU error
switch action {
case "nextturn":
turn := r.FormValue("turn")
errS, errU = h.CommandForceTurn(g, turn)
case "setautos":
dayBool := [7]bool{}
dayBool[0] = r.FormValue("sunday") == "on"
dayBool[1] = r.FormValue("monday") == "on"
dayBool[2] = r.FormValue("tuesday") == "on"
dayBool[3] = r.FormValue("wednesday") == "on"
dayBool[4] = r.FormValue("thursday") == "on"
dayBool[5] = r.FormValue("friday") == "on"
dayBool[6] = r.FormValue("saturday") == "on"
errS, errU = h.CommandSetAutos(g, dayBool)
case "startgame":
exodus := r.FormValue("exodus") == "on"
errS, errU = h.CommandStartGame(g, gFacs, exodus)
case "newgame":
gamename, password := r.FormValue("gamename"), r.FormValue("password")
facname, towin := r.FormValue("facname"), r.FormValue("towin")
errS, errU = h.CommandNewGame(g, password, gamename, facname, towin)
case "dropgame":
errS, errU = h.CommandDropGame(g)
default:
errU = NewError("UNKNOWN ACTION TYPE")
}
if my, bad := Check(errS, "page op home action failure", "action", action, "user", h.User.String(), "game", g); bad {
h.HandleServerError(w, r, my)
} else if errU != nil {
h.HandleUserError(w, r, errU.Error())
} else {
http.Redirect(w, r, r.URL.Path, http.StatusFound)
}
return
}
m := h.DefaultApp()
m["user"] = h.User.String()
if hasG {
m["game"] = g
m["active"] = g.Turn() > 0
}
if gHasF {
m["gfactions"] = gFacs
days := g.AutoDays()
var any bool
for _, b := range days {
if b {
any = true
break
}
}
if !any {
m["noauto"] = true
}
}
oFacs, err := h.M.Faction().Select("owner", h.User.String())
if my, bad := Check(err, "resource error in homepage", "resource", "faction", "owner", h.User); bad {
h.HandleServerError(w, r, my)
//.........这里部分代码省略.........