本文整理匯總了Golang中github.com/mjibson/goon.Goon.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang Goon.Get方法的具體用法?Golang Goon.Get怎麽用?Golang Goon.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mjibson/goon.Goon
的用法示例。
在下文中一共展示了Goon.Get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateVillage
func updateVillage(us UpdateSchedule, g *goon.Goon) error {
village := Village{No: us.VillageNo}
if err := g.Get(&village); err != nil || village.Day <= 0 {
return nil
}
village.Day++
err := g.RunInTransaction(func(g *goon.Goon) error {
vKey := g.Key(village)
q3 := datastore.NewQuery("Person").Ancestor(vKey).Order("CreatedTime")
people := make([]Person, 0, 10)
_, err := g.GetAll(q3, &people)
if err != nil {
return err
}
// 3日目以降のみ投票処理
var posts []Post
if village.Day >= 3 {
posts = Execute(people)
} else if village.Day == 2 {
t := setting.NpcName + "は無殘な死體で見つかった。"
p := Post{Author: "System", AuthorID: "0", Text: t, Time: time.Now(), Type: SystemMessage}
posts = append(posts, p)
p2 := Post{Author: "System", AuthorID: "0", Time: time.Now(), Type: SystemMessage}
p2.Text = setting.SecondDaySystemPost
posts = append(posts, p2)
}
before := make([]Person, len(people))
copy(before, people)
posts = append(posts, Fortune(people)...)
Raid(people)
// Check Dead Person
peaceful := true
for i := range people {
if !before[i].Dead && people[i].Dead {
peaceful = false
t := people[i].Name + "は無殘な死體で見つかった。"
p := Post{Author: "System", AuthorID: "0", Text: t, Time: time.Now(), Type: SystemMessage}
posts = append(posts, p)
}
people[i].VoteTarget = ""
people[i].AbilityTarget = ""
}
if peaceful && village.Day >= 3 {
t := "今日は誰も犠牲者がいないようだ。"
p := Post{Author: "System", AuthorID: "0", Text: t, Time: time.Now(), Type: SystemMessage}
posts = append(posts, p)
}
j := Judge(people)
if j > 0 {
village.Day *= -1
var t string
switch j {
case 1:
t = setting.VillagerWin
case 2:
t = setting.WerewolfWin
case 3:
t = setting.FoxWin
}
p := Post{Author: "System", AuthorID: "0", Text: t, Time: time.Now(), Type: SystemMessage}
posts = append(posts, p)
}
_, err = g.Put(&village)
if err != nil {
return err
}
for i := range posts {
posts[i].Day = village.Day
if posts[i].Day <= -1 {
posts[i].Day = -1
}
posts[i].ParentKey = vKey
_, err = g.Put(&posts[i])
if err != nil {
return err
}
}
for i := 0; i < len(people); i++ {
people[i].ParentKey = vKey
_, err = g.Put(&people[i])
if err != nil {
return err
}
}
us.SetNextUpdateTime(time.Now())
us.ParentKey = vKey
_, err = g.Put(&us)
if err != nil {
return err
}
return nil
}, nil)
if err != nil {
return err
}
return nil
}