add Player model

This commit is contained in:
Andrew Glaze
2025-05-18 16:53:08 -04:00
parent a93308afb1
commit 62260ffc73
11 changed files with 390 additions and 11 deletions

View File

@@ -1,8 +1,5 @@
import Fluent
/// Property wrappers interact poorly with `Sendable` checking, causing a warning for the `@ID` property
/// It is recommended you write your model with sendability checking on and then suppress the warning
/// afterwards with `@unchecked Sendable`.
final class Account: Model, @unchecked Sendable {
static let schema = "accounts"

View File

@@ -0,0 +1,151 @@
import Fluent
final class Player: Model, @unchecked Sendable {
static let schema = "players"
@ID(custom: "id", generatedBy: .database)
var id: Int?
@Field(key: "stamina")
var stamina: Int
@Field(key: "stamina_heal_time")
var staminaHealTime: Date
@Field(key: "boost_point")
var boostPoint: Int
@Field(key: "boss_boost_point")
var bossBoostPoint: Int
@Field(key: "transition_state")
var transitionState: Int
@Field(key: "role")
var role: Int
@Field(key: "name")
var name: String
@Field(key: "last_login_time")
var lastLoginTime: Date
@Field(key: "comment")
var comment: String
@Field(key: "vmoney")
var vmoney: Int
@Field(key: "free_vmoney")
var freeVmoney: Int
@Field(key: "rank_point")
var rankPoint: Int
@Field(key: "star_crumb")
var starCrumb: Int
@Field(key: "bond_token")
var bondToken: Int
@Field(key: "exp_pool")
var expPool: Int
@Field(key: "exp_pooled_time")
var expPooledTime: Date
@Field(key: "leader_character_id")
var leaderCharacterId: Int
@Field(key: "party_slot")
var partySlot: Int
@Field(key: "degree_id")
var degreeId: Int
@Field(key: "birth")
var birth: Int
@Field(key: "free_mana")
var freeMana: Int
@Field(key: "paid_mana")
var paidMana: Int
@Field(key: "enable_auto_3x")
var enableAuto3x: Bool
@Parent(key: "account_id")
var account: Account
@Field(key: "tutorial_step")
var tutorialStep: Int?
@Field(key: "tutorial_skip_flag")
var tutorialSkipFlag: Int?
init() { }
init(
stamina: Int,
staminaHealTime: Date,
boostPoint: Int,
bossBoostPoint: Int,
transitionState: Int,
role: Int,
name: String,
lastLoginTime: Date,
comment: String,
vmoney: Int,
freeVmoney: Int,
rankPoint: Int,
starCrumb: Int,
bondToken: Int,
expPool: Int,
expPooledTime: Date,
leaderCharacterId: Int,
partySlot: Int,
degreeId: Int,
birth: Int,
freeMana: Int,
paidMana: Int,
enableAuto3x: Bool,
account: Account,
tutorialStep: Int?,
tutorialSkipFlag: Int?
) {
self.stamina = stamina
self.staminaHealTime = staminaHealTime
self.boostPoint = boostPoint
self.bossBoostPoint = bossBoostPoint
self.transitionState = transitionState
self.role = role
self.name = name
self.lastLoginTime = lastLoginTime
self.comment = comment
self.vmoney = vmoney
self.freeVmoney = freeVmoney
self.rankPoint = rankPoint
self.starCrumb = starCrumb
self.bondToken = bondToken
self.expPool = expPool
self.expPooledTime = expPooledTime
self.leaderCharacterId = leaderCharacterId
self.partySlot = partySlot
self.degreeId = degreeId
self.birth = birth
self.freeMana = freeMana
self.paidMana = paidMana
self.enableAuto3x = enableAuto3x
self.tutorialStep = tutorialStep
self.tutorialSkipFlag = tutorialSkipFlag
}
static func createDefault(account: Account) -> Player {
return Player(
stamina: 20,
staminaHealTime: Date.now,
boostPoint: 3,
bossBoostPoint: 3,
transitionState: 0,
role: 1,
name: "플레이어",
lastLoginTime: Date.now,
comment: "Nice to meet you.",
vmoney: 0,
freeVmoney: 150,
rankPoint: 10,
starCrumb: 0,
bondToken: 0,
expPool: 0,
expPooledTime: Date.now,
leaderCharacterId: 1,
partySlot: 1,
degreeId: 1,
birth: 19900101,
freeMana: 1000,
paidMana: 0,
enableAuto3x: false,
account: account,
tutorialStep: 0,
tutorialSkipFlag: nil
)
}
}