Commit 96533516 authored by twanvl's avatar twanvl

Changed Pack structures

parent d6b3bbaa
...@@ -1831,68 +1831,66 @@ auto replace: ...@@ -1831,68 +1831,66 @@ auto replace:
############################################################## Card packs ############################################################## Card packs
pack type: pack item:
name: Starter pack name: Common
filter: card.rarity == "common"
pack item:
name: Uncommon
filter: card.rarity == "uncommon"
pack item:
name: Rare
filter: card.rarity == "rare"
pack item:
name: Basic Land
filter: card.type == "Plains"
filter: card.type == "Island"
filter: card.type == "Swamp"
filter: card.type == "Mountain"
filter: card.type == "Forest"
# TODO: support something like this:
#type: cyclic
pack type: pack type:
name: Tournament pack name: Tournament pack
card type: item:
name: Rare name: Rare
amount: 3 amount: 3
filter: card.rarity == "rare" item:
card type:
name: Uncommon name: Uncommon
amount: 9 amount: 9
filter: card.rarity == "uncommon" item:
card type:
name: Common name: Common
amount: 33 amount: 33
filter: card.rarity == "common" item:
card type: name: Basic Land
name: Plains amount: 30
amount: 6
filter: card.type == "Plains"
card type:
name: Island
amount: 6
filter: card.type == "Island"
card type:
name: Swamp
amount: 6
filter: card.type == "Swamp"
card type:
name: Mountain
amount: 6
filter: card.type == "Mountain"
card type:
name: Forest
amount: 6
filter: card.type == "Forest"
pack type: pack type:
name: Booster pack name: Booster pack
card type: item:
name: Rare name: Rare
amount: 1 amount: 1
filter: card.rarity == "rare" item:
card type:
name: Uncommon name: Uncommon
amount: 3 amount: 3
filter: card.rarity == "uncommon" item:
card type:
name: Common name: Common
amount: 11 amount: 11
filter: card.rarity == "common" pack type:
name: Additional common
item:
name: Common
pack type:
name: Additional uncommon
item:
name: Uncommon
pack type: pack type:
name: Additional rare name: Additional rare
card type: item:
name: Rare name: Rare
amount: 1
filter: card.rarity == "rare"
pack type: pack type:
name: Additional common name: Additional special
card type: item:
name: Rare name: Special
amount: 1
filter: card.rarity == "rare"
......
...@@ -53,6 +53,7 @@ IMPLEMENT_REFLECTION(Game) { ...@@ -53,6 +53,7 @@ IMPLEMENT_REFLECTION(Game) {
REFLECT_NO_SCRIPT(card_list_color_script); REFLECT_NO_SCRIPT(card_list_color_script);
REFLECT_NO_SCRIPT(statistics_dimensions); REFLECT_NO_SCRIPT(statistics_dimensions);
REFLECT_NO_SCRIPT(statistics_categories); REFLECT_NO_SCRIPT(statistics_categories);
REFLECT_NO_SCRIPT(pack_items);
REFLECT_NO_SCRIPT(pack_types); REFLECT_NO_SCRIPT(pack_types);
REFLECT_NO_SCRIPT(keyword_match_script); REFLECT_NO_SCRIPT(keyword_match_script);
REFLECT(has_keywords); REFLECT(has_keywords);
......
...@@ -20,6 +20,7 @@ DECLARE_POINTER_TYPE(Style); ...@@ -20,6 +20,7 @@ DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(Game); DECLARE_POINTER_TYPE(Game);
DECLARE_POINTER_TYPE(StatsDimension); DECLARE_POINTER_TYPE(StatsDimension);
DECLARE_POINTER_TYPE(StatsCategory); DECLARE_POINTER_TYPE(StatsCategory);
DECLARE_POINTER_TYPE(PackItem);
DECLARE_POINTER_TYPE(PackType); DECLARE_POINTER_TYPE(PackType);
DECLARE_POINTER_TYPE(KeywordParam); DECLARE_POINTER_TYPE(KeywordParam);
DECLARE_POINTER_TYPE(KeywordMode); DECLARE_POINTER_TYPE(KeywordMode);
...@@ -44,6 +45,7 @@ class Game : public Packaged { ...@@ -44,6 +45,7 @@ class Game : public Packaged {
OptionalScript card_list_color_script; ///< Script that determines the color of items in the card list OptionalScript card_list_color_script; ///< Script that determines the color of items in the card list
vector<StatsDimensionP> statistics_dimensions; ///< (Additional) statistics dimensions vector<StatsDimensionP> statistics_dimensions; ///< (Additional) statistics dimensions
vector<StatsCategoryP> statistics_categories; ///< (Additional) statistics categories vector<StatsCategoryP> statistics_categories; ///< (Additional) statistics categories
vector<PackItemP> pack_items; ///< Types of cards in packs
vector<PackTypeP> pack_types; ///< Types of random card packs to generate vector<PackTypeP> pack_types; ///< Types of random card packs to generate
vector<WordListP> word_lists; ///< Word lists for editing with a drop down list vector<WordListP> word_lists; ///< Word lists for editing with a drop down list
vector<AutoReplaceP> auto_replaces; ///< Things to autoreplace in textboxes vector<AutoReplaceP> auto_replaces; ///< Things to autoreplace in textboxes
......
...@@ -18,13 +18,41 @@ PackType::PackType() ...@@ -18,13 +18,41 @@ PackType::PackType()
IMPLEMENT_REFLECTION(PackType) { IMPLEMENT_REFLECTION(PackType) {
REFLECT(name); REFLECT(name);
REFLECT(enabled); REFLECT(enabled);
REFLECT(card_types); REFLECT(items);
} }
// ----------------------------------------------------------------------------- : CardType void PackType::generate(Set& set, vector<CardP>& out) const {
//%FOR_EACH(card_type, card_types) {
//% card_type->generate(set,out);
//%}
}
// ----------------------------------------------------------------------------- : PackItemRef
PackItemRef::PackItemRef()
: amount(1)
{}
IMPLEMENT_REFLECTION(CardType) { IMPLEMENT_REFLECTION(PackItemRef) {
REFLECT(name); REFLECT(name);
REFLECT(amount); REFLECT(amount);
}
bool PackItemRef::update(Context& ctx) {
return amount.update(ctx);
}
// ----------------------------------------------------------------------------- : PackItem
IMPLEMENT_REFLECTION(PackItem) {
REFLECT(name);
REFLECT(filter); REFLECT(filter);
} }
void PackItem::generate(Set& set, vector<CardP>& out) const {
//%Context& ctx = set.getContext();
//%amount.update(ctx);
//%FOR_EACH(card_type, card_types) {
//% card_type->generate(set,out);
//%}
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <util/reflect.hpp> #include <util/reflect.hpp>
#include <script/scriptable.hpp> #include <script/scriptable.hpp>
DECLARE_POINTER_TYPE(CardType); DECLARE_POINTER_TYPE(PackItemRef);
DECLARE_POINTER_TYPE(Card); DECLARE_POINTER_TYPE(Card);
class Set; class Set;
...@@ -25,24 +25,46 @@ class PackType : public IntrusivePtrBase<PackType> { ...@@ -25,24 +25,46 @@ class PackType : public IntrusivePtrBase<PackType> {
PackType(); PackType();
String name; ///< Name of this pack String name; ///< Name of this pack
vector<CardTypeP> card_types; ///< Cards in this pack
Scriptable<bool> enabled; ///< Is this pack enabled? Scriptable<bool> enabled; ///< Is this pack enabled?
vector<PackItemRefP> items; ///< Cards in this pack
/// Generate a random pack of cards /// Generate a random pack of cards, add them to out
void generate(Set& set, vector<CardP>& out); void generate(Set& set, vector<CardP>& out) const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
// ----------------------------------------------------------------------------- : CardType // ----------------------------------------------------------------------------- : PackItemRef
/// A card type description for playtesting class PackItemRef : public IntrusivePtrBase<PackItemRef> {
class CardType : public IntrusivePtrBase<CardType> {
public: public:
PackItemRef();
String name; ///< Name of this type of cards String name; ///< Name of this type of cards
Scriptable<int> amount; ///< Number of cards of this type Scriptable<int> amount; ///< Number of cards of this type
/// Update scripts, returns true if there is a change
bool update(Context& ctx);
/// Generate random cards, add them to out
void generate(Set& set, vector<CardP>& out) const;
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : PackItem
/// A card type description for playtesting
class PackItem : public IntrusivePtrBase<PackItem> {
public:
String name; ///< Name of this type of cards
OptionalScript filter; ///< Filter to select this type of cards OptionalScript filter; ///< Filter to select this type of cards
/// Generate random cards, add them to out
void generate(Set& set, vector<CardP>& out) const;
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
......
...@@ -15,6 +15,51 @@ ...@@ -15,6 +15,51 @@
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
DECLARE_TYPEOF_COLLECTION(PackTypeP); DECLARE_TYPEOF_COLLECTION(PackTypeP);
DECLARE_TYPEOF_COLLECTION(CardP);
// ----------------------------------------------------------------------------- : RandomCardList
/// A card list that contains the
class RandomCardList : public CardListBase {
public:
RandomCardList(Window* parent, int id, long style = 0);
/// Reset the list
void reset();
/// Add a pack of cards
void add(PackType& pack);
protected:
virtual void getItems(vector<VoidP>& out) const;
virtual void onChangeSet();
private:
vector<CardP> cards;
};
RandomCardList::RandomCardList(Window* parent, int id, long style)
: CardListBase(parent, id, style)
{}
void RandomCardList::reset() {
cards.clear();
}
void RandomCardList::add(PackType& pack) {
pack.generate(*set,cards);
}
void RandomCardList::onChangeSet() {
reset();
CardListBase::onChangeSet();
}
void RandomCardList::getItems(vector<VoidP>& out) const {
out.reserve(cards.size());
FOR_EACH_CONST(c, cards) {
out.push_back(c);
}
}
// ----------------------------------------------------------------------------- : RandomPackPanel // ----------------------------------------------------------------------------- : RandomPackPanel
...@@ -25,6 +70,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) ...@@ -25,6 +70,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
preview = new CardViewer(this, wxID_ANY); preview = new CardViewer(this, wxID_ANY);
card_list = new FilteredCardList(this, wxID_ANY); card_list = new FilteredCardList(this, wxID_ANY);
wxButton* generate = new wxButton(this, wxID_ANY, _BUTTON_("generate pack")); wxButton* generate = new wxButton(this, wxID_ANY, _BUTTON_("generate pack"));
wxRadioButton* seed_random = new wxRadioButton(this, wxID_ANY, _BUTTON_("random seed"));
wxRadioButton* seed_fixed = new wxRadioButton(this, wxID_ANY, _BUTTON_("fixed seed"));
seed = new wxTextCtrl(this, wxID_ANY);
// init sizer // init sizer
wxSizer* s = new wxBoxSizer(wxHORIZONTAL); wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
s->Add(preview, 0, wxRIGHT, 2); s->Add(preview, 0, wxRIGHT, 2);
...@@ -33,11 +81,22 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) ...@@ -33,11 +81,22 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
wxSizer* s4 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack selection")); wxSizer* s4 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack selection"));
packsSizer = new wxFlexGridSizer(0, 2, 4, 8); packsSizer = new wxFlexGridSizer(0, 2, 4, 8);
packsSizer->AddGrowableCol(0); packsSizer->AddGrowableCol(0);
s4->Add(packsSizer, 1, wxEXPAND | wxALL, 4); s4->AddSpacer(2);
s4->Add(packsSizer, 1, wxEXPAND | wxALL & ~wxTOP, 4);
s3->Add(s4, 1, wxEXPAND, 8); s3->Add(s4, 1, wxEXPAND, 8);
wxSizer* s5 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack totals")); wxSizer* s5 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack totals"));
s3->Add(s5, 1, wxEXPAND | wxLEFT, 8); s3->Add(s5, 1, wxEXPAND | wxLEFT, 8);
s3->Add(generate, 0, wxALIGN_BOTTOM | wxLEFT, 8); wxSizer* s6 = new wxBoxSizer(wxVERTICAL);
wxSizer* s7 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("seed"));
s7->Add(seed_random, 0, wxALL, 4);
s7->Add(seed_fixed, 0, wxALL, 4);
wxSizer* s8 = new wxBoxSizer(wxHORIZONTAL);
s8->Add(seed, 1, wxLEFT, 20);
s7->Add(s8, 0, wxALL & ~wxTOP, 4);
s6->Add(s7, 0, 0, 8);
s6->AddStretchSpacer();
s6->Add(generate, 0, wxTOP | wxALIGN_RIGHT, 8);
s3->Add(s6, 0, wxEXPAND | wxLEFT, 8);
s2->Add(s3, 0, wxEXPAND | wxALL & ~wxTOP, 4); s2->Add(s3, 0, wxEXPAND | wxALL & ~wxTOP, 4);
s2->Add(card_list, 1, wxEXPAND); s2->Add(card_list, 1, wxEXPAND);
s->Add(s2, 1, wxEXPAND, 8); s->Add(s2, 1, wxEXPAND, 8);
...@@ -49,17 +108,18 @@ void RandomPackPanel::onChangeSet() { ...@@ -49,17 +108,18 @@ void RandomPackPanel::onChangeSet() {
preview ->setSet(set); preview ->setSet(set);
card_list->setSet(set); card_list->setSet(set);
// TODO: remove or reuse old pack controls if there are any.
// add pack controls // add pack controls
FOR_EACH(pack, set->game->pack_types) { FOR_EACH(pack, set->game->pack_types) {
PackItem i; PackItem i;
i.pack = pack; i.pack = pack;
i.label = new wxStaticText(this, wxID_ANY, pack->name); i.label = new wxStaticText(this, wxID_ANY, pack->name);
i.value = new wxSpinCtrl(this, wxID_ANY, _("0"), wxDefaultPosition, wxSize(50,-1)); i.value = new wxSpinCtrl(this, wxID_ANY, _("0"), wxDefaultPosition, wxSize(50,-1));
//i.value->SetSizeHints(0,0,50,100);
packsSizer->Add(i.label, 0, wxALIGN_CENTER_VERTICAL); packsSizer->Add(i.label, 0, wxALIGN_CENTER_VERTICAL);
packsSizer->Add(i.value, 0, wxEXPAND | wxALIGN_CENTER); packsSizer->Add(i.value, 0, wxEXPAND | wxALIGN_CENTER);
packs.push_back(i); packs.push_back(i);
} }
Layout(); Layout();
} }
......
...@@ -40,6 +40,7 @@ class RandomPackPanel : public SetWindowPanel { ...@@ -40,6 +40,7 @@ class RandomPackPanel : public SetWindowPanel {
private: private:
CardViewer* preview; ///< Card preview CardViewer* preview; ///< Card preview
FilteredCardList* card_list; ///< The list of cards FilteredCardList* card_list; ///< The list of cards
wxTextCtrl* seed; ///< Seed value
wxFlexGridSizer* packsSizer; wxFlexGridSizer* packsSizer;
wxFlexGridSizer* totalsSizer; wxFlexGridSizer* totalsSizer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment