예제 #1
0
파일: lobby.go 프로젝트: TF2Stadium/Helen
func (Lobby) LobbyServerReset(so *wsevent.Client, args struct {
	ID *uint `json:"id"`
}) interface{} {

	player := chelpers.GetPlayer(so.Token)
	lob, tperr := lobby.GetLobbyByID(*args.ID)

	if player.SteamID != lob.CreatedBySteamID && (player.Role != helpers.RoleAdmin && player.Role != helpers.RoleMod) {
		return errors.New("You are not authorized to reset server.")
	}

	if tperr != nil {
		return tperr
	}

	if lob.State == lobby.Ended {
		return errors.New("Lobby has ended")
	}

	if err := rpc.ReExecConfig(lob.ID, false); err != nil {
		return err
	}

	return emptySuccess
}
예제 #2
0
파일: lobby.go 프로젝트: TF2Stadium/Helen
//Start sets lobby.State to LobbyStateInProgress, calls SubNotInGamePlayers after 5 minutes
func (lobby *Lobby) Start() {
	rows := db.DB.Model(&Lobby{}).Where("id = ? AND state <> ?", lobby.ID, InProgress).Update("state", InProgress).RowsAffected
	if rows != 0 { // if == 0, then game is already in progress
		go rpc.ReExecConfig(lobby.ID, false)

		// var playerids []uint
		// db.DB.Model(&LobbySlot{}).Where("lobby_id = ?", lobby.ID).Pluck("player_id", &playerids)

		// for _, id := range playerids {
		// 	player, _ := GetPlayerByID(id)
		// 	lobby.AfterPlayerNotInGameFunc(player, 5*time.Minute, func() {
		// 		lobby.Substitute(player)
		// 	})
		// }
	}
}