generated from admin/template
полная переделка кода с знанием смысла not null (и с 3мя типами карт)
This commit is contained in:
+42
-111
@@ -1,123 +1,54 @@
|
|||||||
Table card {
|
Table card_common {
|
||||||
card_id int [pk]
|
card_id int [pk]
|
||||||
pokemon_id int [not null]
|
set_id int
|
||||||
card_description text [not null] // у карт того же покемона бывают разные описания
|
card_type text [not null, check: `in ("pokemon", "trainer", "energy")`] // pokemon OR trainer OR energy
|
||||||
|
|
||||||
// данные, не влияющие на игру
|
// общие данные (у pokemon И trainer И energy)
|
||||||
card_rarity int // зависит от того, какими будут сами данные. скорее всего если Common => card_rarity == 0
|
card_name text
|
||||||
card_year int [not null] // год выпуска...
|
card_year int [not null]
|
||||||
card_set_no int [not null] // номер сета...
|
card_rarity int [not null] // 0 = Common, 1 = Uncommon, 2 = Rare, etc.
|
||||||
illustrator_id int [not null]
|
illustrator_id int // fk
|
||||||
|
|
||||||
// игровые данные
|
|
||||||
card_hp int [not null, check: `card_hp > 0`]
|
|
||||||
card_attack_id int [not null]
|
|
||||||
// отступление = в своём роде "атака"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Table pokemon {
|
Table card_pokemon {
|
||||||
pokemon_id int [pk]
|
card_id int [pk]
|
||||||
pokemon_name text [not null]
|
// pokemon
|
||||||
pokemon_height_m numeric [not null]
|
pokemon_name text [not null, check: `card_type == "pokemon"`]
|
||||||
pokemon_weight_kg numeric [not null]
|
// pokeinfo
|
||||||
pokemon_stage int // опять же, зависит от самих данных. если Base, то pokemon_stage == 0
|
pokemon_hp int [not null, check: `card_hp > 0`]
|
||||||
|
pokemon_type int [not null] // 0 = Normal, 1 = Fire, 2 = Water, etc.
|
||||||
|
pokemon_stage text [not null, check: `in ("basic", "s1", "s2")`]
|
||||||
|
pokemon_evolves_from text
|
||||||
|
pokemon_dex_no int [not null]
|
||||||
|
pokemon_description text [not null]
|
||||||
|
pokemon_height_m numeric [not null, check: `pkmn_height > 0`]
|
||||||
|
pokemon_weight_kg numeric [not null, check: `pkmn_weight > 0`]
|
||||||
|
|
||||||
|
pokemon_retreat_cost int [not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table card_trainer {
|
||||||
|
card_id int [pk]
|
||||||
|
trainer_name text [not null]
|
||||||
|
trainer_type text [not null, check: `trainer_type in ("item", "helper", "stadium")`]
|
||||||
|
trainer_description text [not null]
|
||||||
|
trainer_ruleset text [not null] // заметки внизу
|
||||||
|
}
|
||||||
|
|
||||||
|
Table card_energy {
|
||||||
|
card_id int [pk]
|
||||||
|
energy_type text [not null]
|
||||||
|
energy_name text [not null]
|
||||||
}
|
}
|
||||||
|
|
||||||
Table illustrator {
|
Table illustrator {
|
||||||
illustrator_id int [pk]
|
illustrator_id int [pk]
|
||||||
illustrator_name text [not null]
|
illustrator_name text // бывает и пустым, см. Энергия (трава)
|
||||||
}
|
}
|
||||||
|
|
||||||
// бывает максимум 4 атаки у карты (см. Tyranitar EX 111/115)
|
|
||||||
// но бывают и карты без атак, так что not null не ставим
|
|
||||||
// а id атаки сверяется с собранием всех атак... гдето...
|
|
||||||
|
|
||||||
Table attack1 {
|
|
||||||
attack1_id int [pk]
|
|
||||||
attack1_name text
|
|
||||||
attack1_description text
|
|
||||||
attack1_display bool [check: `attack1_name == ""`] // если названия нет, то атаки нет, соответственно её не существует...
|
|
||||||
attack1_energy_type text // normal, fire, water, fighting, т.д. при null атаки нет
|
|
||||||
attack1_energy_cost int // с нулевой энергией атаки бывают
|
|
||||||
attack1_damage int // бывают и атаки, направленные только на снижение какого-либо стата противника, не наносящие урон
|
|
||||||
}
|
|
||||||
|
|
||||||
Table attack2 {
|
|
||||||
attack2_id int [pk]
|
|
||||||
attack2_name text
|
|
||||||
attack2_description text
|
|
||||||
attack2_display bool [check: `attack2_name == ""`]
|
|
||||||
attack2_energy_type text
|
|
||||||
attack2_energy_cost int
|
|
||||||
attack2_damage int
|
|
||||||
}
|
|
||||||
|
|
||||||
Table attack3 {
|
|
||||||
attack3_id int [pk]
|
|
||||||
attack3_name text
|
|
||||||
attack3_description text
|
|
||||||
attack3_display bool [check: `attack3_name == ""`]
|
|
||||||
attack3_energy_type text
|
|
||||||
attack3_energy_cost int
|
|
||||||
attack3_damage int
|
|
||||||
}
|
|
||||||
|
|
||||||
Table attack4 {
|
|
||||||
attack4_id int [pk]
|
|
||||||
attack4_name text
|
|
||||||
attack4_description text
|
|
||||||
attack4_display bool [check: `attack4_name == ""`]
|
|
||||||
attack4_energy_type text
|
|
||||||
attack4_energy_cost int
|
|
||||||
attack4_damage int
|
|
||||||
}
|
|
||||||
|
|
||||||
// выбор атаки из этих 4х возможных атак
|
|
||||||
|
|
||||||
Table chosen_attack {
|
|
||||||
chosen_id int [pk]
|
|
||||||
attack1_id int
|
|
||||||
attack2_id int
|
|
||||||
attack3_id int
|
|
||||||
attack4_id int
|
|
||||||
}
|
|
||||||
|
|
||||||
// выбрали. ID выбранной атаки находится в chosen_id
|
|
||||||
// теперь смотрим, можно ли эту атаку использовать
|
|
||||||
|
|
||||||
Table attack_energy_cost {
|
|
||||||
energy_cost_id int [pk]
|
|
||||||
chosen_id int [not null]
|
|
||||||
energy_quantity int [check: `energy_amount - chosen_energy_cost >= 0`] // проверяем, хватает ли игроку энергии, чтобы воспользоваться выбранной атакой
|
|
||||||
}
|
|
||||||
|
|
||||||
Table card_attack {
|
|
||||||
card_attack_id int [pk]
|
|
||||||
card_id int [not null]
|
|
||||||
chosen_id int [not null] // с этой выбранной атакой делаем вычисления
|
|
||||||
|
|
||||||
// «Почему связующая таблица card_attack необходима для хранения атак, а не запись attack_id напрямую в таблицу card?»
|
|
||||||
// для добавления модификаторов к уже существующиму кол-ву урона, наносимому карте
|
|
||||||
pokemon_weakness_energy_type text // fighting
|
|
||||||
pokemon_weakness_amount text // x2
|
|
||||||
pokemon_resistance_energy_type text // normal
|
|
||||||
pokemon_resistance_amount text // -20
|
|
||||||
attack_damage_result int // урон, после того, как его прогнали через модификаторы
|
|
||||||
}
|
|
||||||
|
|
||||||
// ВАЖНО: Энергия == элементы
|
|
||||||
|
|
||||||
|
|
||||||
Ref: "card"."pokemon_id" > "pokemon"."pokemon_id"
|
Ref: "card_common"."illustrator_id" > "illustrator"."illustrator_id"
|
||||||
Ref: "card"."illustrator_id" > "illustrator"."illustrator_id"
|
Ref: "card_common"."card_id" -? "card_pokemon"."card_id"
|
||||||
Ref: "card"."card_attack_id" > "card_attack"."card_attack_id"
|
Ref: "card_common"."card_id" -? "card_trainer"."card_id"
|
||||||
|
Ref: "card_common"."card_id" -? "card_energy"."card_id"
|
||||||
Ref: "attack1"."attack1_id" ?<? "chosen_attack"."attack1_id"
|
|
||||||
Ref: "attack2"."attack2_id" ?<? "chosen_attack"."attack2_id"
|
|
||||||
Ref: "attack3"."attack3_id" ?<? "chosen_attack"."attack3_id"
|
|
||||||
Ref: "attack4"."attack4_id" ?<? "chosen_attack"."attack4_id"
|
|
||||||
|
|
||||||
Ref: "card_attack"."card_id" > "card"."card_id"
|
|
||||||
Ref: "card_attack"."chosen_id" > "chosen_attack"."chosen_id"
|
|
||||||
|
|
||||||
Ref: "attack_energy_cost"."chosen_id" > "chosen_attack"."chosen_id"
|
|
||||||
Reference in New Issue
Block a user