diff --git a/examples/idle/src/Characters.js b/examples/idle/src/Characters.js deleted file mode 100644 index 9fb1e123..00000000 --- a/examples/idle/src/Characters.js +++ /dev/null @@ -1,418 +0,0 @@ -import { Constants } from "@croquet/worldcore"; - -export function CharacterName(n) { - return Constants.Characters[n]; -} - -export function CharacterCount() { - return Constants.Characters.length; -} - -Constants.Characters = [ - "A Balrog of Morgoth", - "A Bucket of Water", - "A Dalek", - "A Dementor", - "A Minion", - "A Roomba with a Knife", - "A Trained Chimp", - "Aeon Flux", - "Aladdin", - "Albus Dumbledore", - "Alvin the Chipmunk", - "An Angry Goose", - "An Oompa Loompa", - "Angelica Pickles", - "Aquaman", - "Ariel", - "Aslan the Lion", - "Augustus Gloop", - "Goldfinger", - "Austin Powers", - "Babar the Elephant", - "Baby Yoda", - "Bambi", - "Barbie", - "Barney the Dinosaur", - "Baron Munchausen", - "Bart Simpson", - "Batman", - "Batgirl", - "Beetlejuice", - "Bellatrix Lestrange", - "Betty Boop", - "Big Bird", - "Bigfoot", - "Bilbo Baggins", - "Bizarro Superman", - "Black Panther", - "Black Widow", - "Bluto", - "Boba Fett", - "Bobby Hill", - "Bojack Horseman", - "Boomhauer", - "Boromir", - "Boss Baby", - "Brainy Smurf", - "Brock Sampson", - "Buffy the Vampire Slayer", - "Bugs Bunny", - "Buzz Lightyear", - "C-3PO", - "Caillou", - "Cap'n Crunch", - "Captain America", - "Captain Hook", - "Captain Jack Sparrow", - "Captain Marvel", - "Captain Nemo", - "Captain Planet", - "Captain Underpants", - "Carmen Sandiego", - "Cartman", - "Caspar the Friendly Ghost", - "Catbus", - "Catra", - "Catwoman", - "Charlie Brown", - "Clifford the Big Red Dog", - "Clippy", - "Cobra Commander", - "Conan the Barbarian", - "Cookie Monster", - "Coraline", - "Count Chocula", - "Count Dracula", - "Count von Count", - "Cruella De Vil", - "Cthulhu", - "Curious George", - "Daffy Duck", - "Daphne", - "Daria", - "Darth Vader", - "Data", - "Deadpool", - "Dick Tracy", - "Doctor Doom", - "Doctor Girlfriend", - "Doctor Manhattan", - "Doctor Strange", - "Dolores Umbridge", - "Donald Duck", - "Donkey Kong", - "Dora the Explorer", - "Dorothy", - "Dr. Doofenshmirtz", - "Dr. Frank-n-furter", - "Dr. Zoidberg", - "Dumbo", - "E.T.", - "Ebenezer Scrooge", - "Eeyore", - "Elmer Fudd", - "Elmo", - "Elsa", - "Emperor Kuzco", - "Emperor Palpatine", - "Éowyn", - "Ferris Bueller", - "Fezzik", - "Frankenstein's monster", - "Fred Flintstone", - "Freddie Kruger", - "Frodo Baggins", - "Frosty the Snowman", - "Galadriel", - "Gandalf the Grey", - "Garfield", - "Gaston", - // "Geordi La Forge", - "Geppetto", - "Gimli", - "Gir", - "GLaDOS", - "Glinda the Good Witch", - "Godzilla", - "Goku", - "Gollum", - "Goofy", - "Green Lantern", - "Groot", - "Hagrid", - "HAL-9000", - "Han Solo", - "Hank Hill", - "Hannibal Lecter", - "Harley Quinn", - "Harry Potter", - "He-Man", - "Hellboy", - "Hello Kitty", - "Hermione Granger", - "Homer Simpson", - "Indiana Jones", - "Inigo Montoya", - "Inspector Columbo", - "Inspector Gadget", - "Invader Zim", - "Iron Man", - "Jabba the Hutt", - "Jack Skellington", - "Jafar", - "James Bond", - "James T. Kirk", - "Jar Jar Binks", - // "Jason Voorhees", - "Jean-Luc Picard", - "Jessica Rabbit", - "Jiminy Cricket", - "John Shaft", - "Jonny Quest", - // "Judge Dredd", - "Judy Hopps", - "Jughead", - "Katniss Everdeen", - "Kenny", - "Kermit the Frog", - "Kim Possible", - "King Kong", - "Kirby", - "Kratos", - "Kronk", - "Krusty the Clown", - "Krypto the Superdog", - "Lando Calrissian", - "Lara Croft", - "Lassie", - "Legolas", - "Leslie Knope", - "Lex Luthor", - "Lightning McQueen", - "Link", - "Lisa Simpson", - "Lois Lane", - "Loki", - "Lola Bunny", - "Lord Voldemort", - "Luigi", - "Luke Skywalker", - "Luna Lovegood", - "Lurch", - "Lydia Deetz", - "MacGyver", - "Magneto", - "Maleficient", - "Mario", - "Marion Ravenwood", - "Mary Poppins", - "Master Chief", - "McGruff the Crime Dog", - "Megamind", - "Megatron", - "Meowth", - "Merlin", - "Michael Corleone", - "Mickey Mouse", - "Minerva McGonagall", - "Mini-me", - "Mirror Universe Spock", - "Miss Piggy", - "Mothman", - "Mr. Bean", - "Mr. Burns", - "Mr. Fantastic", - "Mr. Freeze", - "Mr. Krabs", - "Mr. Mxyzptlk", - "Mr. Snuffleupagus", - "Mr. Toad", - "Mr. Tumnus", - "Mrs. Potts", - "Ms. Frizzle", - "Mulan", - "Mystique", - "Ned Flanders", - "Neville Longbottom", - "Nick Fury", - "Nosferatu", - "Obi-Wan Kenobi", - "Olive Oyl", - "Oogie Boogie", - "Optimus Prime", - "Oscar the Grouch", - "Pac-Man", - "Paddington Bear", - "Papa Smurf", - "Patrick Star", - "Pennywise the Clown", - "Pepé Le Pew", - "Peppa Pig", - "Perry the Platypus", - "Peter Griffin", - "Peter Pan", - "Piglet", - "Pikachu", - "Pinhead", - "Plankton", - "Poison Ivy", - "Popeye", - "Porky Pig", - "Princess Bubblegum", - "Princess Leia", - "Princess Peach", - "Professor Moriarty", - "Puss-in-Boots", - "Pyramid Head", - "Q", - "R2-D2", - "Rambo", - "Rapunzel", - "Red Skull", - "Richie Rich", - "Robin the Boy Wonder", - "Robocop", - "Rocket Raccoon", - "Rocky Balboa", - "Roger Rabbit", - "Ron Weasley", - "Ronald McDonald", - "Rudolph the Red-Nosed Reindeer", - "Sabrina the Teenage Witch", - "Sailor Moon", - "Samus Aran", - "Sandy Cheeks", - "Santa Claus", - "Saruman the White", - "Sauron", - "Scar", - "Scooby Doo", - "Scotty", - "Scrappy Doo", - "Scrooge McDuck", - "Severus Snape", - "Shaggy", - "She-Hulk", - "She-Ra", - "Shelob", - "Sherlock Holmes", - "Shrek", - "Sir Topham Hatt", - "Skeletor", - "Slenderman", - "Slimer", - "Smaug", - "Smurfette", - "Snoopy", - "Snow White", - "Solid Snake", - "Sonic the Hedgehog", - "Speed Racer", - "Speedy Gonzales", - "Spock", - "Spongebob Squarepants", - "Squidward Tentacles", - "Squirrel Girl", - "Starscream", - "Lt. Sulu", - "Supergirl", - "Superman", - "Tank Girl", - "Tarzan", - "Thanos", - "The Babadook", - "The Brave Little Toaster", - "The Cat in the Hat", - "The Cowardly Lion", - "The Creature from the Black Lagoon", - "The Doctor", - "The Dread Pirate Roberts", - "The Dude", - "The Easter Bunny", - "The Energizer Bunny", - "The Flash", - "The Fonz", - "The Genie", - "The Grim Reaper", - "The Grinch", - "The Human Torch", - "The Incredible Hulk", - "The Invisible Girl", - "The Iron Giant", - "The Joker", - "The Jolly Green Giant", - "The Kool-Aid Man", - "The Loch Ness Monster", - "The Lone Ranger", - "The Mad Hatter", - "The Man in the Yellow Hat", - "The Mummy", - "The Other Mother", - "The Penguin", - "The Phantom of the Opera", - "The Pillsbury Dough Boy", - "The Pink Panther", - "The Predator", - "The Roadrunner", - "The Sarlacc", - "The Scarecrow", - "The Stay-Puft Marshmallow Man", - "The Swedish Chef", - "The Tasmanian Devil", - "The Terminator", - "The Tin Man", - "The Tooth Fairy", - "The Velveteen Rabbit", - "The Very Hungry Caterpillar", - "The Wicked Witch of the West", - "The Wizard of Oz", - "Thomas the Tank Engine", - "Thor", - "Tigger", - "Tinker Bell", - "Tintin", - "Tiny Tim", - "Tonto", - "Toto (too)", - "Totoro", - "Treebeard", - "Tuxedo Mask", - "Tweety Bird", - "Twilight Sparkle", - "Tyrion Lannister", - "Lt. Uhura", - "Uncle Fester", - "Ursula", - "Vegeta", - "Velma", - "Veruca Salt", - "Violet Beauregarde", - "Vito Corleone", - "Vizzini", - "WALL-E", - "Waluigi", - "Wario", - "Wednesday Addams", - "Wesley Crusher", - "Wile E. Coyote", - "Willy Wonka", - "Wilson (volleyball)", - "Winnie-the-Pooh", - // "Wishbone", - "Wolverine", - "Wonder Woman", - "Woody", - "Worf", - "Xena, Warrior Princess", - "Yoda (non-baby)", - "Yogi Bear", - "Yosemite Sam", - "Yoshi", - "Yzma", - "Zaphod Beeblebrox", - "Zapp Brannigan", - "Zorro" -]; - - diff --git a/examples/idle/src/Models.js b/examples/idle/src/Models.js index bd578592..4c0e088f 100644 --- a/examples/idle/src/Models.js +++ b/examples/idle/src/Models.js @@ -2,150 +2,7 @@ import { AccountManager, ModelRoot, Actor, mix, ModelService, Behavior, Shuffle import { Nickname } from "./Names"; import { BigNum } from "./BigNum"; import { Resource } from "./Resource"; -import { Lackeys } from "./Population"; -import { Baskets } from "./Upgrade"; - -//------------------------------------------------------------------------------------------ -// -- Resource ----------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------ - -// class Resource extends Actor { - - -// get account() {return this._account} -// get key() {return this._key} - -// init(options) { -// super.init(options); -// this.count = new BigNum(0); -// this.multiplier = 1; -// this.boost = 0; -// } - -// increment(bn) { -// this.count.increment(bn); -// } - -// get production() { // per tick -// const total = new BigNum(); -// this.account.domain.forEach(pop => { -// const prod = pop.production(this.key); -// total.increment(prod); -// }); -// total.scale(this.multiplier); -// return total; -// } - -// produce() { -// this.increment(this.production); -// } - -// } -// Resource.register('Resource'); - -//------------------------------------------------------------------------------------------ -// -- Population --------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------ - -// class Population extends Actor { - -// get account() {return this._account} - -// init(options) { -// super.init(options); -// this.count = 0; -// this.size = 1; -// } - -// get population() {return this.count * this.size} - -// buy() { -// const price = this.price; -// if (!this.account.canAfford(price)) { -// console.log("Too much!"); return; -// } -// this.account.spend(price); -// this.count += 1; -// } - -// } -// Population.register('Population'); - -//------------------------------------------------------------------------------------------ -// -- Lackeys ------------------------------------------------------------------------------ -//------------------------------------------------------------------------------------------ - -// class Lackeys extends Population { - -// init(options) { -// super.init(options); -// this.count = 0; -// this.subscribe("input", "xDown", this.test); -// } - -// get price() { -// const base = { Food: new BigNum(15)}; -// const markup = 1.15**this.count; -// base.Food.scale(markup); -// return base; -// } - -// production(key) { -// const scale = this.population/20; //per tick -// switch (key) { -// default: return new BigNum(); -// case "Food": return new BigNum(1*scale); -// case "Wood": return new BigNum(0.1*scale); -// } -// } - -// test() { -// console.log(this.production.Food.text); -// console.log(this.production.Wood.text); -// } - - -// } -// Lackeys.register('Lackeys'); - -//------------------------------------------------------------------------------------------ -// -- Tech --------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------ - -// class Tech extends Actor { - -// get account() {return this._account} -// get price() {return { Wood: new BigNum(20)}} -// get name() { return "Basketweaving" } -// get hint() { return "+1% food production" } -// get effect() { return {Food: 0.01}} - -// init(options) { -// super.init(options); -// this.subscribe("input", "tDown", this.buy); -// } - -// buy() { -// const price = this.price; -// if (!this.account.canAfford(price)) { -// console.log("Too much!"); return; -// } - -// console.log("Bought Tech!"); - -// // const account = this.account; -// // for (const key in this.effect) { -// // const resource = account.resources.get(key); -// // if (resource) resource.multiplier += this.effect.key; -// // } - -// const food = this.account.resources.get("Food"); -// food.multiplier += 0.01; -// this.account.say("changed"); -// } - -// } -// Tech.register('Tech'); +import { Lackey, Hut } from "./Population"; //------------------------------------------------------------------------------------------ // -- Account ------------------------------------------------------------------------------ @@ -157,7 +14,8 @@ class MyAccount extends Account { return { "BigNum": BigNum, "Resource": Resource, - "Lackeys": Lackeys + "Lackey": Lackey, + "Hut": Hut }; } @@ -179,24 +37,23 @@ class MyAccount extends Account { this.resources.set("iron", new Resource()); this.domain = new Map(); - this.domain.set("lackeys", new Lackeys()); + this.domain.set("lackey", new Lackey()); + this.domain.set("hut", new Hut()); + + this.upgrades = new Set(); + this.upgrades.add("Baskets"); + this.upgrades.add("Axes"); + this.listen("clickResource", this.onClick); this.listen("buyPopulation", this.onBuyPopulation); - this.subscribe("input", "tDown", this.tech); + // this.subscribe("input", "tDown", this.tech); this.future(100).tick(); } - tech() { - const baskets = new Baskets(); - baskets.apply(this); - } - tick() { - this.resources.forEach((resource, key) => { - resource.produce(); - }); + this.resources.forEach(resource => resource.produce()); this.say("changed"); this.future(100).tick(); @@ -249,6 +106,36 @@ class MyAccount extends Account { }); } + techPrice(tech) { + switch (tech) { + default: return {}; + case "Baskets": return {wood: new BigNum(100)}; + case "Axes": return {wood: new BigNum(10), stone: new BigNum(10)}; + } + } + + techHint(tech) { + switch (tech) { + default: return "None"; + case "Baskets": return {wood: "Double food production"}; + case "Axes": return {wood: "Double food production"}; + } + } + + buyTech(tech) { + switch (tech) { + default: break; + case "Baskets": + this.resources.get("food").multiplier *= 2; + break; + case "Axes": + this.resources.get("wood").multiplier *= 2; + break; + } + this.say("changed"); + } + + } MyAccount.register('MyAccount'); diff --git a/examples/idle/src/Population.js b/examples/idle/src/Population.js index c23797c9..a1e6bcb7 100644 --- a/examples/idle/src/Population.js +++ b/examples/idle/src/Population.js @@ -9,6 +9,7 @@ export class Population { constructor() { this.count = 0; this.size = 1; + this.multiplier = 1; } get population() {return this.count * this.size} @@ -17,10 +18,10 @@ export class Population { } //------------------------------------------------------------------------------------------ -// -- Lackeys ------------------------------------------------------------------------------ +// -- Lackey ------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ -export class Lackeys extends Population { +export class Lackey extends Population { constructor() { super(); @@ -41,5 +42,31 @@ export class Lackeys extends Population { wood: new BigNum(0.1*scale) }; } +} + +//------------------------------------------------------------------------------------------ +// -- Hut ------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------ + +export class Hut extends Population { + constructor() { + super(); + this.name = "Huts"; + this.size = 10; + } + + get price() { + const food = new BigNum(100); + food.scale(this.markup); + return {food}; + } + + get production() { + const scale = this.population/10; //per tick + return { + food: new BigNum(1*scale), + wood: new BigNum(0.1*scale) + }; + } } diff --git a/examples/idle/src/Questions.js b/examples/idle/src/Questions.js deleted file mode 100644 index d70497c2..00000000 --- a/examples/idle/src/Questions.js +++ /dev/null @@ -1,106 +0,0 @@ -import { Constants } from "@croquet/worldcore"; - -export function Question(n) { - return Constants.Questions[n]; -} - -export function QuestionCount() { - return Constants.Questions.length; -} - -Constants.Questions = [ - "Who would win a battle to the death?", - "Who would win a battle of wits?", - "Who should be king of the world?", - "Who takes the longest to get ready in the morning?", - "Who would you rather be stranded on a desert island with?", - "Who would you rob a bank with?", - "Who needs to be in therapy?", - "Who should be utterly erased from existence?", - "Who would help you hide a body?", - "Who would be most useful during a zombie apocalypse?", - "Who's the worst at their job?", - "Who has the worst pickup line?", - "Who would you be most surprised to see working at McDonald's?", - "Who has the best fashion sense?", - "Who's the worst tipper?", - "Who would you trust with your darkest secret?", - "Who would you ask to help you move?", - "Who would you send back in time to kill Hitler?", - "Who would you take a road trip with?", - "Who's the fairest one of all?", - "Who would you build an IKEA bookcase with?", - "Who should rescue little Timmy from the well?", - "Who would you trust to watch the baby?", - "Who would make the best cult leader?", - "Who is secretly a sleeper agent?", - "Who would you spend a weekend in Vegas with?", - "Who would make the worst middle-school gym teacher?", - "Who would win a freestyle rap battle?", - "Who knows how to hold a grudge?", - 'Who would you rather sleep with?', - "Who would win a talent show?", - "Who should drive the getaway car?", - "Who would you avoid if you ran into them at Walmart?", - "Who would you crash a wedding with?", - "Who needs a vacation?", - "Who looks best in drag?", - "Who had the longest emo phase?", - "Who picks up the check?", - "Who's missing the big picture?", - "Who would you not get into a hot tub with?", - "Who smells the best?", - "Who smells the worst?", - "Who would be the easiest to frame for murder?", - "Who ate the last cookie?", - "Who deserves to be taken down a notch?", - "Who needs hug?", - "Who looks best in a swimsuit?", - "Who would you go dumpster diving with?", - "Who would be first to be voted off the island?", - "Who would make the worst ex?", - "Who would ghost you?", - "Who parties the hardest?", - "Who can't hold their liquor?", - "Who's the most diligent about recycling?", - "Who wants to speak to the manager?", - "Who's the brains of the operation?", - "Who's the worst boss?", - "Who's the best boss?", - "Who's the cat who won't cop out when there's danger all about?", - "Who secretly suffers from massive self-loathing?", - "Who had the worst childhood?", - "Who would you go to Disneyland with?", - "Who would you rather have a romantic dinner with?", - "Who's the absolute worst?", - "Who really needs a makeover?", - "Who do you want to switch places with for a day?", - "Who's the best kisser?", - "Who's the worst kisser?", - "Who would you trust to disarm a ticking time bomb?", - "Who is a ticking time bomb?", - "Who has the best secret lair?", - "Who would you trust to clean the bathroom?", - "Who should star in their own rom-com?", - "Who would you be least surprised to discover was a serial killer?", - "Who has the best hair?", - "Who would be the worst roommate?", - "Who would be the best roommate?", - "Who always gets picked last for dodgeball?", - "Who should be homecoming queen?", - "Who has the sickest moves?", - "Who's the most metal?", - "Who's the most punk?", - "Who's just phoning it in?", - "Who throws the best parties?", - "Who would you like to see host the Oscars?", - "Who should have their own late night talk show?", - "Who would you go to for relationship advice?", - "Who's the biggest gossip?", - "Who's the biggest dumpster fire?", - "Who would you not want to owe money to?", - "Who is trying too hard?", - "Who would you trust to watch your stuff while you're in the bathroom?", - "Who would you ask for directions?", - "Who would you not want to sit next to on an airplane?" -]; diff --git a/examples/idle/src/Upgrade.js b/examples/idle/src/Upgrade.js deleted file mode 100644 index 562bb2fe..00000000 --- a/examples/idle/src/Upgrade.js +++ /dev/null @@ -1,24 +0,0 @@ -import { BigNum } from "./BigNum"; - -export class Baskets { - - constructor() { - this.name = "Baskets"; - this.hint = "Doubles food production"; - } - - get cost() { - const wood = new BigNum(100); - return {wood}; - } - - apply(account) { - console.log("baskets"); - const food = account.resources.get("food"); - food.multiplier *= 2; - // account.calculateProduction(); - // console.log(wood.multiplier); - // console.log(wood.perSecond.text); - account.say("changed"); - } -} \ No newline at end of file diff --git a/examples/idle/src/Views.js b/examples/idle/src/Views.js index 973fc673..21629b7e 100644 --- a/examples/idle/src/Views.js +++ b/examples/idle/src/Views.js @@ -27,6 +27,7 @@ class GameWidget extends Widget2 { this.bg = new CanvasWidget2({account, parent: this, color: [0,1,1], autoSize: [1,1]}); this.domain = new DomainPanel({account, parent: this.bg, translation:[0,0], size: [200, 100]}); + this.population = new PopulationPanel({account, parent: this.bg, translation: [0,105], size:[200, 100]}); this.food = new ResourceWidget({account, parent: this.bg, translation:[240,0], size: [150, 150], key: "food"}); this.wood = new ResourceWidget({account, parent: this.bg, translation:[440,0], size: [150, 150], key: "wood"}); @@ -34,17 +35,16 @@ class GameWidget extends Widget2 { this.iron = new ResourceWidget({account, parent: this.bg, translation:[840,0], size: [150, 150], key: "iron"}); - // this.wood = new ResourceWidget({account, parent: this.bg, translation:[500,0], size: [220, 150], key: "wood"}); - // this.iron = new ResourceWidget({account, parent: this.bg, translation:[750,0], size: [200, 150], key: "iron"}); - // this.domain = new DomainWidget({account, parent: this.bg, translation:[0,0], size: [200, 100]}); - // this.tech = new TechPanel({account, parent: this.bg, translation:[0,-100], anchor: [0,1], pivot: [0,1], size: [200, 100]}); - + this.tech = new TechPanel({account, parent: this.bg, translation:[300,-500], anchor: [0,1], pivot: [0,1], size: [200, 100]}); this.subscribe(this.account.id, {event: "changed", handling: "oncePerFrame"}, this.tally); } tally() { this.domain.tally(); + this.population.tally(); + this.tech.tally(); + this.food.tally(); this.wood.tally(); this.stone.tally(); @@ -84,25 +84,44 @@ class DomainPanel extends VerticalWidget2 { get account() {return this._account} build() { - this.set({margin: 5}); const account = this.account; - const title = this.account.nickname + "'s\ndomain"; + const title = account.nickname + "'s\ndomain"; this.title = new TextWidget2({parent: this, color: [1,1,1], textColor: [0,0,0], point: 12, height:50, noWrap: true, text: title}); this.population = new TextWidget2({parent: this, color: [1,1,1], textColor: [0,0,0], point: 12, height:50, noWrap: true}); - this.lackeys = new PopulationWidget({account, key: "lackeys", parent: this, height:50}); this.tally(); } tally() { const account = this.account; - const pop = this.account.population; - const citizens = pop +" "+ this.account.mood + ((pop>1)? " followers":" follower"); - const text = "Population:\n" + ((pop>0) ? citizens : this.account.nickname); + const pop = account.population; + const citizens = pop +" "+ account.mood + ((pop>1)? " followers":" follower"); + const text = "Population:\n" + ((pop>0) ? citizens : account.nickname); this.population.set({text}); + } + +} - this.lackeys.tally(); +//------------------------------------------------------------------------------------------ +//-- PopulationPanel ----------------------------------------------------------------------- +//------------------------------------------------------------------------------------------ + +class PopulationPanel extends VerticalWidget2 { + + get account() {return this._account} + build() { + const account = this.account; + this.destroyChildren(); + this.set({margin: 5}); + this.lackey = new PopulationWidget({account, key: "lackey", parent: this, height:90}); + this.hut = new PopulationWidget({account, key: "hut", parent: this, height:90}); + this.tally(); + } + + tally() { + this.lackey.tally(); + this.hut.tally(); } } @@ -126,7 +145,7 @@ class PopulationButton extends ButtonWidget2 { tally() { const pop = this.account.domain.get(this.key); - const text = this.key +": " + pop.count; + const text = pop.name +": " + pop.count; this.label.set({text}); } @@ -192,26 +211,28 @@ class ResourceWidget extends VerticalWidget2 { } -// //------------------------------------------------------------------------------------------ -// //-- TechPanel ---------------------------------------------------------------------------- -// //------------------------------------------------------------------------------------------ - -// class TechPanel extends VerticalWidget2 { - -// get account() {return this._account} - -// build() { -// const account = this.account; -// this.a = new TechWidget({account, parent: this, height: 20, point: 12, color: [1,1,1], textColor: [0,0,0], text:"Wicker Baskets" }); +//------------------------------------------------------------------------------------------ +//-- TechPanel ----------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------ -// } +class TechPanel extends VerticalWidget2 { -// tally() { + get account() {return this._account} + build() { + this.set({margin: 5}); + this.destroyChildren(); + new TextWidget2({parent: this, height: 50, color: [1,1,1], testColor: [0,0,0], text: "Technology"}); + const account = this.account; + account.upgrades.forEach(key => { + new TechWidget({account, key, parent: this, height: 90}); + }); + } -// } + tally() { + } -// } +} //------------------------------------------------------------------------------------------ //-- TechWidget ---------------------------------------------------------------------------- @@ -224,13 +245,12 @@ class TechWidget extends VerticalWidget2 { build() { const account = this.account; - this.button = new ButtonWidget2({parent: this, height: 50, point: 12, color: [1,1,1], textColor: [0,0,0], text:"Basketweaving" }); + this.button = new ButtonWidget2({parent: this, height: 50, point: 12, color: [1,1,1], textColor: [0,0,0]}); this.button.label.destroy(); this.button.label = new VerticalWidget2({parent: this.button.frame, autoSize: [1,1], border: [5, 5, 5, 5],}); - - this.title = new TextWidget2({ parent: this.button.label, style: "bold", color: [1,1,1], point: 16, text: "Stone Axe" }); - this.effect = new TextWidget2({parent: this.button.label, height: 20, point: 10, color: [1,1,1], textColor: [0,0,0], text:"+1% food production" }); - this.price = new PriceWidget({parent: this, account}); + this.title = new TextWidget2({ parent: this.button.label, style: "bold", color: [1,1,1], point: 16, text: this.key }); + this.effect = new TextWidget2({parent: this.button.label, height: 20, point: 10, color: [1,1,1], textColor: [0,0,0], text:"Double food production" }); + this.price = new PriceWidget({parent: this, account, height:20, price: {wood: new BigNum(100), stone: new BigNum(1)}}); } tally() { @@ -239,13 +259,7 @@ class TechWidget extends VerticalWidget2 { } - - - - - - -//------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------- //-- MyViewRoot ---------------------------------------------------------------------------- //------------------------------------------------------------------------------------------