Add cards to proper categories, fix problem colors
This commit is contained in:
parent
72c6e49a06
commit
d4fff245bc
4 changed files with 79 additions and 42 deletions
42
Classes/CardInfo.gd
Normal file
42
Classes/CardInfo.gd
Normal file
|
@ -0,0 +1,42 @@
|
|||
extends Object
|
||||
|
||||
class_name CardInfo
|
||||
|
||||
var id := "unknown"
|
||||
var name := "Unknown card"
|
||||
var subname := "--"
|
||||
var colors := []
|
||||
var keywords := []
|
||||
var traits := []
|
||||
var requirements := {}
|
||||
var cost := 0
|
||||
var power := 0
|
||||
var type := "None"
|
||||
var text := "This card does not exist, if you see it it's because something failed loading"
|
||||
var rarity := "UR"
|
||||
var bonus := 0
|
||||
var opponentPower := 0
|
||||
|
||||
func _init(cardEntry: Dictionary):
|
||||
if not cardEntry.empty():
|
||||
id = cardEntry.ID
|
||||
name = cardEntry.Name
|
||||
subname = cardEntry.Subname
|
||||
colors = cardEntry.Element
|
||||
keywords = cardEntry.Keywords
|
||||
traits = cardEntry.Traits
|
||||
type = cardEntry.Type
|
||||
text = cardEntry.Text
|
||||
rarity = cardEntry.Rarity
|
||||
if cardEntry.has("Power"):
|
||||
power = cardEntry.Power
|
||||
if cardEntry.has("Cost"):
|
||||
cost = cardEntry.Cost
|
||||
if cardEntry.has("ProblemBonus"):
|
||||
bonus = cardEntry.ProblemBonus
|
||||
if cardEntry.has("Requirement"):
|
||||
requirements = cardEntry.Requirement
|
||||
elif cardEntry.has("ProblemRequirement"):
|
||||
requirements = cardEntry.ProblemRequirement
|
||||
if cardEntry.has("ProblemOpponentPower"):
|
||||
opponentPower = cardEntry.ProblemOpponentPower
|
|
@ -3,46 +3,6 @@ extends Node
|
|||
var loadedSets := {}
|
||||
var loadedCards := {}
|
||||
|
||||
class CardInfo:
|
||||
var id := "unknown"
|
||||
var name := "Unknown card"
|
||||
var subname := "--"
|
||||
var colors := []
|
||||
var keywords := []
|
||||
var traits := []
|
||||
var requirements := {}
|
||||
var cost := 0
|
||||
var power := 0
|
||||
var type := "None"
|
||||
var text := "This card does not exist, if you see it it's because something failed loading"
|
||||
var rarity := "UR"
|
||||
var bonus := 0
|
||||
var opponentPower := 0
|
||||
|
||||
func _init(cardEntry: Dictionary):
|
||||
if not cardEntry.empty():
|
||||
id = cardEntry.ID
|
||||
name = cardEntry.Name
|
||||
subname = cardEntry.Subname
|
||||
colors = cardEntry.Element
|
||||
keywords = cardEntry.Keywords
|
||||
traits = cardEntry.Traits
|
||||
type = cardEntry.Type
|
||||
text = cardEntry.Text
|
||||
rarity = cardEntry.Rarity
|
||||
if cardEntry.has("Power"):
|
||||
power = cardEntry.Power
|
||||
if cardEntry.has("Cost"):
|
||||
cost = cardEntry.Cost
|
||||
if cardEntry.has("ProblemBonus"):
|
||||
bonus = cardEntry.ProblemBonus
|
||||
if cardEntry.has("Requirement"):
|
||||
requirements = cardEntry.Requirement
|
||||
elif cardEntry.has("ProblemRequirement"):
|
||||
requirements = cardEntry.ProblemRequirement
|
||||
if cardEntry.has("ProblemOpponentPower"):
|
||||
opponentPower = cardEntry.ProblemOpponentPower
|
||||
|
||||
func _ready():
|
||||
# Search for sets in MLPData
|
||||
var dir := Directory.new()
|
||||
|
|
|
@ -30,8 +30,36 @@ func add_card(cardID: String):
|
|||
item.cardSubname = data.subname
|
||||
item.showCost = has_cost(data.type)
|
||||
item.cardCost = data.cost
|
||||
if data.type == "Problem":
|
||||
item.color = to_color_ids(data.requirements.keys())
|
||||
else:
|
||||
item.color = to_color_ids(data.colors)
|
||||
blocks["entry"].add_child(item)
|
||||
var cat := get_card_group(data)
|
||||
add_to_card_group(cat, item)
|
||||
|
||||
func get_card_group(item: CardInfo) -> String:
|
||||
match item.type:
|
||||
"Friend":
|
||||
# Entry if req is 0, friend otherwise
|
||||
if item.requirements.size() < 1:
|
||||
return "entry"
|
||||
return "friend"
|
||||
"Event":
|
||||
#TODO some events are entry (color-fixing)
|
||||
return "event"
|
||||
"Resource":
|
||||
#TODO some resources are entry (color-fixing)
|
||||
return "resource"
|
||||
"Troublemaker":
|
||||
return "troublemaker"
|
||||
"Problem":
|
||||
return "problem"
|
||||
"Mane Character":
|
||||
return "mane"
|
||||
|
||||
func add_to_card_group(cat: String, item: Node):
|
||||
blocks[cat].add_child(item)
|
||||
labels[cat].visible = true
|
||||
|
||||
var colorTable = {
|
||||
"Loyalty": "blue",
|
||||
|
@ -45,6 +73,7 @@ var colorTable = {
|
|||
func to_color_ids(ogcolors: Array) -> String:
|
||||
var newcol := []
|
||||
for ogcol in ogcolors:
|
||||
ogcol = (ogcol as String).trim_prefix("Not ")
|
||||
if colorTable.has(ogcol):
|
||||
newcol.push_back(colorTable[ogcol])
|
||||
match newcol.size():
|
||||
|
|
|
@ -19,6 +19,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://Scenes/Board/Card.gd"
|
||||
}, {
|
||||
"base": "Object",
|
||||
"class": "CardInfo",
|
||||
"language": "GDScript",
|
||||
"path": "res://Classes/CardInfo.gd"
|
||||
}, {
|
||||
"base": "Reference",
|
||||
"class": "Resources",
|
||||
"language": "GDScript",
|
||||
|
@ -37,6 +42,7 @@ _global_script_classes=[ {
|
|||
_global_script_class_icons={
|
||||
"Board": "",
|
||||
"Card": "",
|
||||
"CardInfo": "",
|
||||
"Resources": "",
|
||||
"ScatterCard": "",
|
||||
"Stack": ""
|
||||
|
|
Loading…
Reference in a new issue