コード例 #1
0
func (cntr *Controller) PlayerBaseMake(c web.C, w http.ResponseWriter, r *http.Request) {
	var (
		db           = cntr.db
		charaMakeAPI CharaMakeAPI
		baseRolls    = map[string][]int{
			"Strength":     {6, 3},
			"Constitution": {6, 3},
			"Power":        {6, 3},
			"Dextality":    {6, 3},
			"Appeal":       {6, 3},
			"Size":         {6, 2, 6},
			"Intelligence": {6, 2, 6},
			"Education":    {6, 2, 3},
		}
	)

	User := model.User{}
	r.ParseForm()
	User.UUID = r.FormValue("UUID")
	db.Find(&User)

	playerBase, history := util.CreatePlayerBase(baseRolls)
	player := util.CreatePlayerStatus(playerBase)

	log.Println(playerBase)
	log.Println(player)

	playerBase.UserID = User.ID
	playerBase.Name = User.Name
	player.UserID = User.ID
	player.JobID, _ = strconv.Atoi(r.FormValue("JobID"))

	charaMakeAPI.BaseStatus = playerBase
	charaMakeAPI.Status = player
	charaMakeAPI.DiceHistory = history
	log.Println(charaMakeAPI)

	encoder := json.NewEncoder(w)
	encoder.Encode(charaMakeAPI)
}
コード例 #2
0
func (cntr *Controller) PlayerGenerate(c web.C, w http.ResponseWriter, r *http.Request) {
	var db = cntr.db

	User := model.User{}
	r.ParseForm()
	User.UUID = r.FormValue("UUID")
	db.Find(&User)

	log.Println(r.FormValue("data"))

	var charaMakeAPI CharaMakeAPI

	json.Unmarshal([]byte(r.FormValue("data")), &charaMakeAPI)

	baseStatus := charaMakeAPI.BaseStatus
	status := charaMakeAPI.Status

	db.Create(&baseStatus)
	status.PlayerID = baseStatus.ID

	db.Create(&status)

	log.Println(charaMakeAPI)
}