diff --git a/CHANGELOG.md b/CHANGELOG.md index 6598fa6d..5da7a676 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,8 +22,8 @@ Added `Buff` as a skill *BALANCE* - purify - - 1 effect from all cryps at level 2 - - removes all effects from all cryps at l3 + - 1 effect from all constructs at level 2 + - removes all effects from all constructs at l3 - invert - fx for buffs when applied to enemies diff --git a/COMBOS.md b/COMBOS.md index 4cd2063f..d41124fc 100644 --- a/COMBOS.md +++ b/COMBOS.md @@ -5,7 +5,7 @@ specs [spec [bonus amount, [r g b]] # Playthrough -cryps join game +constructs join game stats randomised initial stash drops diff --git a/ECONOMY.md b/ECONOMY.md index cd15efb1..e40a894c 100644 --- a/ECONOMY.md +++ b/ECONOMY.md @@ -23,9 +23,9 @@ Base specs have a base 3 cost ### Actual Costs -- Costs increase as more of an item is used on cryps in the game +- Costs increase as more of an item is used on constructs in the game - The cost increases by the base cost for every 6 allocations of base item -- Allocation is based on all cryps in the game +- Allocation is based on all constructs in the game ### Example ### @@ -33,15 +33,15 @@ Round #1 All costs are base costs # Player #1 and Player #2 (They both bought the same things) -Cryp #1 Strike (Attack + RR), (2 + 1 + 1) = (4) cost -Cryp #1 Empower (Buff + RR), (2 + 1 + 1) = (4) cost -Cryp #3 Attack, 2 cost +Construct #1 Strike (Attack + RR), (2 + 1 + 1) = (4) cost +Construct #1 Empower (Buff + RR), (2 + 1 + 1) = (4) cost +Construct #3 Attack, 2 cost Total cost - 10 Round #2 -Items used on cryps include: +Items used on constructs include: Red x 8 Attack x 4 @@ -52,9 +52,9 @@ The costs of red for round #2 are now (1 + 1) = 2 If they were to buy the same skill setup it would be as follows: # Player #1 and Player #2 (They both bought the same things) -Cryp #1 Strike (Attack + RR), (2 + 2 + 2) = (6) cost -Cryp #1 Empower (Buff + RR), (2 + 2 + 2) = (6) cost -Cryp #3 Attack, 2 cost +Construct #1 Strike (Attack + RR), (2 + 2 + 2) = (6) cost +Construct #1 Empower (Buff + RR), (2 + 2 + 2) = (6) cost +Construct #3 Attack, 2 cost Total cost - 14 diff --git a/NODES.md b/NODES.md index 16042cab..076b466e 100644 --- a/NODES.md +++ b/NODES.md @@ -46,4 +46,4 @@ Rare `increased speed, increased cooldowns` - Increased stat - ??? Related Notables -# ??? Cryps need to have a minimum of X of the cryp stat to learn a skill # +# ??? Constructs need to have a minimum of X of the construct stat to learn a skill # diff --git a/README.md b/README.md index 74cb4925..96116cc9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Cryps ("creeps") +# Constructs ("creeps") ## Combat @@ -30,7 +30,7 @@ resolve phase: | reduction | absorption? | durations | -## Cryp Alignments +## Construct Alignments Natural Selection ================ @@ -92,7 +92,7 @@ Path to Destruction Damage & Destruction ------------------------- -cryps walking the path to destruction have forsaken themselves in order to gain ruinous power. +constructs walking the path to destruction have forsaken themselves in order to gain ruinous power. no price is too high, they gladly harm themselves and allies to amplify the destruction they wreak on everything around them specialise in magical damage dealing @@ -124,7 +124,7 @@ Universal Chaos The only constant is change. ---------------------------- -Cryps aligning themselves with the forces of chaos believe that constant change is the only truth in the universe. +Constructs aligning themselves with the forces of chaos believe that constant change is the only truth in the universe. They harness its power to manipulate physical reality as well as control and disrupt the flow of battle. They blend between physical and astral forms, constantly shifting throughout time and space. diff --git a/ROADMAP.md b/ROADMAP.md index 2f0608eb..7f9ff085 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,7 +1,7 @@ ### Road Map ### -# NOW Phase 1 (Dev -> Alpha) +# NOW Phase 1 (Dev -> Alpha) Form company structure Brainstorm Names? @@ -22,7 +22,7 @@ Combat animations Make in game shop Payment processors / CC etc Handler for game purchases - MTX - Cryp Avatars + MTX - Construct Avatars MTX - Skill anims Setup company bank accounts @@ -32,7 +32,7 @@ Setup company bank accounts Player Events e.g. chatwheel Matchmaking + ELO / Leaderboard -Game skill private fields +Game skill private fields Refine artwork, icons, scaling etc Music @@ -41,4 +41,23 @@ Marketing materials Videos Twitch Advertisments? - Information \ No newline at end of file + Information + + + +# china shit +You need to read the details more carefully. Playsaurus messed up: + +1. They launched in China without registering a trademark + +2. A competitor registered the trademark after 3 months of their launch + +3. They continued to sell for 4 years under a name trademarked by another company, making $73,000+ yearly from that one country + +Now, they complain about it on Reddit, even though China is a 'First to File' company. + +The fault lies entirely with Playsaurus, nothing illegal occurred here. + +https://www.trademarknow.com/blog/first-to-file-versus-first... + +This situation could have occurred in many other countries - the difference is probably that the competitor is content to just sell in China, under a Chinese name, whereas products sold anywhere else would need to use the English name. \ No newline at end of file diff --git a/SPECS.md b/SPECS.md index 543247df..cd8d089f 100644 --- a/SPECS.md +++ b/SPECS.md @@ -4,16 +4,16 @@ Numbers are placeholder `Specs get a bonus dependent on the total of Red / Green / Blue in player skills & specs` # Example to meet 5 red gem bonus from skills only -In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has `Snare` +In your player Construct #1 has `Strike`, Construct #2 has `Slay` and `Heal`, Construct #3 has `Snare` - RR skill `Strike` contributes 2 red gems to the total red gems (2 total) - RG skill `Slay` contributes 1 red gem to the total red gems (3 total) - GG skill `Heal` contirubtes 0 red gems to the total red gems (3 total) - RR skill `Snare` contirubtes 2 red gems to the total red gems (5 total) -# Advanced specs also require a minimum number of Red / Green / Blue gems on the cryp to take effect +# Advanced specs also require a minimum number of Red / Green / Blue gems on the construct to take effect - Tier 1 Basic specs (Damage / Health / Defense) will have no requirements - Advanced specs will require a certain threshold of red / green / blue gems to be enabled - - Provided spec requirements are met, all specs will add gems to the cryp + - Provided spec requirements are met, all specs will add gems to the construct # Starting from scratch with a vbox @@ -26,9 +26,9 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has Combine 2 Red + 'Attack' -> Strike Combine 2 Red + 'Basic Damage Spec' -> Red Damage - Cryp #1 -> Give Strike & Red Damage Spec -> Strike + 1 x Red Damage Spec - Cryp #2 -> Give Attack -> Attack - Cryp #3 -> Give Stun -> Stun + Construct #1 -> Give Strike & Red Damage Spec -> Strike + 1 x Red Damage Spec + Construct #2 -> Give Attack -> Attack + Construct #3 -> Give Stun -> Stun Player Total (4 Red + 2 Basic gems) @@ -37,17 +37,17 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has - Buy 2 reds & 2 green & 2 blue (all available colour items) - Buy 2 Basic Damage Spec (item) - - Cryp #2 Unequip Attack + - Construct #2 Unequip Attack - Combine 2 Green + 'Attack' -> Heal - - Cryp #3 Unequip Stun + - Construct #3 Unequip Stun - Combine 2 Blue + 'Stun' -> Ruin - Combine 2 Red + 'Basic Damage Spec' -> Red Damage - Cryp #1 -> Give Red Damage items -> Strike + 2 x Red Damage Spec (6R) - Cryp #2 -> Give Heal item -> Heal (2G) - Cryp #3 -> Give Ruin item -> Ruin (2B) + Construct #1 -> Give Red Damage items -> Strike + 2 x Red Damage Spec (6R) + Construct #2 -> Give Heal item -> Heal (2G) + Construct #3 -> Give Ruin item -> Ruin (2B) ## Round 3 @@ -58,9 +58,9 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has - Combine 2 Red + 'Stun' -> Strangle - Combine 2 Red + 'Block' -> Parry - Cryp #1 -> Give 'Stun' & 'Strangle' -> Strike, Stun, Strangle + 2 x Red Damage Spec (10R) - Cryp #2 -> 'No change' -> Heal (2G) - Cryp #3 -> Give Attack item & 2 Basic Damage Spec -> Attack + Ruin + 2 x Basic Damage Spec (2B) + Construct #1 -> Give 'Stun' & 'Strangle' -> Strike, Stun, Strangle + 2 x Red Damage Spec (10R) + Construct #2 -> 'No change' -> Heal (2G) + Construct #3 -> Give Attack item & 2 Basic Damage Spec -> Attack + Ruin + 2 x Basic Damage Spec (2B) ## Round 4 @@ -70,18 +70,18 @@ In your player Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has - Combine 2 Red + 'Attack' -> Strike - Combine 2 Red + 'Buff' -> Empower - - Cryp #1 Unequip 2 x Red Damage spec, Equip Empower -> Strike, Stun, Strangle, Empower (8R) + - Construct #1 Unequip 2 x Red Damage spec, Equip Empower -> Strike, Stun, Strangle, Empower (8R) - Combine 'Strike' + 2 x Red Damage spec -> 'Increased Strike Damage spec' - ### Note 'Increased Strike Damage spec' requires 8R on the cryp + ### Note 'Increased Strike Damage spec' requires 8R on the construct - Cryp #1 Equip Increased Strike Damage spec -> Strike, Stun, Strangle, Empower + Increased Strike Damage Spec (14R) - Cryp #2 -> 'No change' -> Heal - Cryp #3 -> 'No change' -> Attack + Ruin + 2 x Basic Damage Spec + Construct #1 Equip Increased Strike Damage spec -> Strike, Stun, Strangle, Empower + Increased Strike Damage Spec (14R) + Construct #2 -> 'No change' -> Heal + Construct #3 -> 'No change' -> Attack + Ruin + 2 x Basic Damage Spec ## Round 5 - We already lost cause we went all in on 1 red cryp like a noob + We already lost cause we went all in on 1 red construct like a noob ### Generic Specs @@ -96,7 +96,7 @@ Maximum 35% inc hp Maximum 50% inc speed # Basic Class Spec -`Base` -> +2 red, +2 green +2 blue gems on cryp +`Base` -> +2 red, +2 green +2 blue gems on construct # Basic Duration ### Increased Damage Combos ### @@ -182,32 +182,32 @@ Maximum +35% inc blue shield and 35% inc red shield ## Upgraded Attack Spec Combos # Increased Strike Damage (Combine Strike + Red Damage Spec x 2) -Cryp Requires `8 red gems` +Construct Requires `8 red gems` Adds `6 red gems` `Base` -> 15% increased strike damage `Player Bonus` 15 red gems -> +15% // 20 red gems -> +20% // 30 red gems -> +30% Maximum 80% increased strike damage # Improved Heal (Combine Heal + Healing Spec x 2) -Cryp Requires `8 green gems` +Construct Requires `8 green gems` `Base` -> 15% increased heal healing `Player Bonus` 15 green gems -> +15% // 20 green gems -> +20% // 30 green gems -> +30% Maximum 80% increased heal healing # Increased Blast Damage (Combine Blast + Blue Spec x 2) -Cryp Requires `8 blue gems` +Construct Requires `8 blue gems` `Base` -> 15% increased blast damage `Player Bonus` 15 blue gems -> +15% // 20 blue gems -> +20% // 30 blue gems -> +30% Maximum 80% increased blast damage # Increased Slay Damage (Combine Slay + Red Damage Spec + Healing Spec) -Cryp Requires `4 red 4 green gems` +Construct Requires `4 red 4 green gems` `Base` -> 15% increased slay damage `Player Bonus` (8R + 8G) gems -> +15% // (10R + 10G) gems -> +20% // (15R + 15G) gems -> +30% Maximum 80% increased slay damage # Increased Banish Damage (Combine Slay + Red Damage Spec + Blue Damage Spec) -Cryp Requires `4 red 4 blue gems` +Construct Requires `4 red 4 blue gems` `Base` -> 15% increased slay damage `Player Bonus` (8R + 8B) gems -> +15% // (10R + 10B) gems -> +20% // (15R + 15B) gems -> +30% Maximum 80% increased banish damage diff --git a/WORKLOG.md b/WORKLOG.md index 3204dd55..5f442b7e 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -24,8 +24,8 @@ Tidy edges on game UI blue + defensive green - purify - - 1 effect from all cryps at level 2 - - removes all effects from all cryps at l3 + - 1 effect from all constructs at level 2 + - removes all effects from all constructs at l3 - invert - fx for buffs when applied to enemies @@ -102,7 +102,7 @@ push events $$$ * Items * Colour scheme - * number of cryps + * number of constructs * Highlight (dota) colour * fx colours + styles diff --git a/client/assets/styles/game.css b/client/assets/styles/game.css index aa313bdb..70f8b403 100644 --- a/client/assets/styles/game.css +++ b/client/assets/styles/game.css @@ -36,7 +36,7 @@ } -.opponent .game-cryp { +.opponent .game-construct { align-items: flex-start; grid-template-rows: min-content min-content min-content 2fr; grid-template-columns: 1fr 1fr; @@ -47,12 +47,12 @@ "avatar target"; } -.opponent .game-cryp .name { +.opponent .game-construct .name { margin-bottom: 0; margin-top: 0.25em; } -.game-cryp { +.game-construct { display: grid; /*justify-items: center;*/ @@ -74,7 +74,7 @@ transition-timing-function: ease; } -.game-cryp .targeting { +.game-construct .targeting { grid-area: target; display: flex; flex-flow: column; @@ -84,36 +84,36 @@ white-space: nowrap; } -.game-cryp .img { +.game-construct .img { grid-area: avatar; } -.game-cryp .name { +.game-construct .name { width: 100%; margin-bottom: 0.25em; text-align: center; grid-area: name; } -.game-cryp .stats { +.game-construct .stats { grid-area: stats; display: flex; flex-flow: row; } -.game-cryp figure { +.game-construct figure { padding: 0 0.5em; display: flex; flex-flow: column; } -.game-cryp figcaption { +.game-construct figcaption { white-space: nowrap; font-size: 100%; } @media (max-width: 1500px) { - .game-cryp figure { + .game-construct figure { padding: 0 0.25em; } @@ -123,7 +123,7 @@ } */} -.game-cryp .skills { +.game-construct .skills { grid-area: skills; display: flex; flex-flow: column-reverse; @@ -131,13 +131,13 @@ } /*@media (max-width: 1000px) { - .game-cryp .skills { + .game-construct .skills { flex-flow: column; } } */ -.game-cryp .effects { +.game-construct .effects { grid-area: effects; font-size: 1.5em; white-space: nowrap; @@ -153,7 +153,7 @@ margin-right: 0.5em; } -.game-cryp button { +.game-construct button { color: #888; flex: 1 1 100%; padding: 0; @@ -161,35 +161,35 @@ border-width: 0px; } -.game-cryp button.active { +.game-construct button.active { color: whitesmoke; } -.game-cryp button[disabled], .game-cryp button[disabled]:hover { +.game-construct button[disabled], .game-construct button[disabled]:hover { color: #333333; text-decoration: line-through } -.game-cryp button:hover { +.game-construct button:hover { color: whitesmoke; } -.game-cryp.ko { +.game-construct.ko { animation: none; opacity: 0.35; filter: grayscale(100%); } -.game-cryp.ko button:hover { +.game-construct.ko button:hover { color: #333; } -.game-cryp.unfocus { +.game-construct.unfocus { opacity: 0.65; filter: blur(5px); } -.game-cryp.unfocus.ko { +.game-construct.unfocus.ko { filter: blur(5px) grayscale(100%); } @@ -202,18 +202,18 @@ left: 50%; } -CRYP DAMAGE +CONSTRUCT DAMAGE -.game-cryp.active-skill { +.game-construct.active-skill { filter: drop-shadow(0 0 0.2em silver); /*border-color: silver;*/ } -.game-cryp.red-damage { +.game-construct.red-damage { filter: drop-shadow(0 0 0.2em red); color: red; - /*ensure cryp doesn't get opacity lowered because of being KO before the KO animation*/ + /*ensure construct doesn't get opacity lowered because of being KO before the KO animation*/ opacity: 1; /*border-color: red;*/ @@ -232,7 +232,7 @@ CRYP DAMAGE /*border-top: 1px solid red;*/ } -.game-cryp.blue-damage { +.game-construct.blue-damage { filter: drop-shadow(0 0 0.2em blue); color: blue; opacity: 1; @@ -252,7 +252,7 @@ CRYP DAMAGE /*border-top: 1px solid blue;*/ } -.game-cryp.green-damage { +.game-construct.green-damage { filter: drop-shadow(0 0 0.2em green); color: green; opacity: 1; @@ -272,7 +272,7 @@ CRYP DAMAGE /*border-top: 1px solid green;*/ } -.game-cryp.purple-damage { +.game-construct.purple-damage { filter: drop-shadow(0 0 0.2em purple); color: purple; border-color: purple; diff --git a/client/assets/styles/instance.css b/client/assets/styles/instance.css index c06a63cd..7692b6ab 100644 --- a/client/assets/styles/instance.css +++ b/client/assets/styles/instance.css @@ -11,7 +11,7 @@ "top top info" "vbox vbox info" "equip equip info" - "cryps cryps info"; + "constructs constructs info"; } @media (max-width: 1920px) { @@ -33,7 +33,7 @@ } .instance .scoreboard { - grid-area: cryps; + grid-area: constructs; } .instance-ui-btn { @@ -60,8 +60,8 @@ margin-top: 1.5em; } -.instance .cryps { - grid-area: cryps; +.instance .constructs { + grid-area: constructs; } .instance .equip { @@ -148,16 +148,16 @@ cursor: pointer; } -/* CRYP LIST */ +/* CONSTRUCT LIST */ -.cryp-list { - grid-area: cryps; +.construct-list { + grid-area: constructs; display: grid; grid-template-columns: 1fr 1fr 1fr; } -.instance-cryp, .instance-cryp-active { +.instance-construct, .instance-construct-active { display: grid; grid-template-rows: min-content min-content min-content 1fr min-content; grid-template-areas: @@ -177,17 +177,17 @@ transition-timing-function: ease; */} -.instance-cryp:first-child, .instance-cryp-active:first-child { +.instance-construct:first-child, .instance-construct-active:first-child { margin-left: 0; border-left-width: 1px; } -.cryp-list .name { +.construct-list .name { grid-area: name; margin-bottom: 0.5em; } -.cryp-list .avatar { +.construct-list .avatar { grid-area: avatar; object-fit: contain; background-size: contain; @@ -196,28 +196,28 @@ pointer-events: none; } -.cryp-list .name { +.construct-list .name { text-align: center; } -.cryp-list .avatar figure { +.construct-list .avatar figure { margin: 0; height: 80%; text-align: center; box-sizing: border-box; } -.cryp-list .avatar figcaption { +.construct-list .avatar figcaption { font-size: 90%; } -.cryp-list .skills { +.construct-list .skills { grid-area: skills; display: flex; border-width: 0px; } -.cryp-list .skills button { +.construct-list .skills button { flex: 1; border-width: 0px; } @@ -236,7 +236,7 @@ } } */ -.cryp-list .specs { +.construct-list .specs { margin-top: 1em; grid-area: specs; display: flex; @@ -245,18 +245,18 @@ border-width: 0px; } -.cryp-list .specs figure { +.construct-list .specs figure { flex: 1; border: 0; align-items: center; text-align: center; } -.cryp-list .specs figcaption { +.construct-list .specs figcaption { font-size: 75%; } -.cryp-list .stats { +.construct-list .stats { grid-area: stats; display: grid; grid-template-rows: 1fr 3fr; @@ -267,11 +267,11 @@ border-width: 0px; } -.cryp-list .stats figcaption { +.construct-list .stats figcaption { font-size: 75%; } -.cryp-list .stats .icons { +.construct-list .stats .icons { grid-area: st; display: flex; flex-flow: row; @@ -289,25 +289,25 @@ fill: none; } -.cryp-list .stat-icon { +.construct-list .stat-icon { width: 100%; } -.cryp-list .stats .damage-label { +.construct-list .stats .damage-label { grid-area: dl; display: flex; justify-content: center; color: #666; } -.cryp-list .stats .speed-label { +.construct-list .stats .speed-label { grid-area: sl; display: flex; justify-content: center; color: #666; } -.cryp-list .stats .life-label { +.construct-list .stats .life-label { grid-area: ll; display: flex; justify-content: center; diff --git a/client/assets/styles/instance.mobile.css b/client/assets/styles/instance.mobile.css index e8a7ff34..333a7fbe 100644 --- a/client/assets/styles/instance.mobile.css +++ b/client/assets/styles/instance.mobile.css @@ -7,12 +7,12 @@ "top" "controls" "vbox" - "cryps" + "constructs" } /* Default view */ .instance .equip { display: none; } .instance .info { display: none; } - .instance .cryp-list { display: none; } + .instance .construct-list { display: none; } .vbox { grid-area: vbox; display: grid; @@ -31,13 +31,13 @@ .vbox-combiner { margin-left: 0; } - /* Toggled view (cryps)*/ + /* Toggled view (constructs)*/ #toggle-vbox-label { text-align: center; border: 2px solid #555; } #toggle-vbox-label:after{ - content: "Cryps"; + content: "Constructs"; } #toggle-vbox:checked ~ #toggle-vbox-label:after{ @@ -54,8 +54,8 @@ display: initial; } - #toggle-vbox:checked ~ .cryp-list { - grid-area: cryps; + #toggle-vbox:checked ~ .construct-list { + grid-area: constructs; display: grid; justify-content: center; @@ -75,12 +75,12 @@ margin-right: 0.5em; } - .cryp-list .skills { + .construct-list .skills { flex-flow: row; align-items: stretch; } - .instance-cryp { + .instance-construct { grid-row: 2; display: grid; grid-template-rows: min-content 1fr; @@ -95,20 +95,20 @@ transition-timing-function: ease; } - .instance-cryp .skills { + .instance-construct .skills { display: none; } - .instance-cryp .specs { + .instance-construct .specs { display: none; } - .instance-cryp .stats { + .instance-construct .stats { display: none; } - .instance-cryp-active { + .instance-construct-active { grid-row: 1; grid-column: 1 / 3; display: grid; @@ -129,11 +129,11 @@ transition-timing-function: ease; } - .instance-cryp-active img { + .instance-construct-active img { width: 55px; } - /* Cryp Stuff */ + /* Construct Stuff */ } \ No newline at end of file diff --git a/client/assets/styles/styles.css b/client/assets/styles/styles.css index 27c33658..d6736a5e 100644 --- a/client/assets/styles/styles.css +++ b/client/assets/styles/styles.css @@ -2,7 +2,7 @@ GLOBAL */ -html, body, #cryps { +html, body, #constructs { /*width: 100%;*/ margin: 0; @@ -61,7 +61,7 @@ figure { text-align: center; } -#cryps { +#constructs { padding: 0 2em; display: grid; grid-template-columns: 1fr 8fr; @@ -277,13 +277,13 @@ button[disabled] { flex-flow: column; } -#cryps input, #cryps select { +#constructs input, #constructs select { border-color: #444; background-color: #333; border-radius: 0; } -#cryps input:focus { +#constructs input:focus { border-color: whitesmoke; } @@ -349,7 +349,7 @@ header { MENU */ -.menu-cryps { +.menu-constructs { display: grid; grid-template-rows: min-content min-content; @@ -358,14 +358,14 @@ header { "list"; } -.menu-cryps .list { +.menu-constructs .list { grid-area: list; display: grid; grid-template-columns: repeat(3, 1fr); } -.menu-cryp-ctr { +.menu-construct-ctr { /*flex: 0 0 30%;*/ display: flex; @@ -374,7 +374,7 @@ header { justify-content: center; } -.spawn-btn .menu-cryp { +.spawn-btn .menu-construct { border: 1px solid #333; color: #333; display: flex; @@ -399,7 +399,7 @@ header { opacity: 0 } -.menu-cryp { +.menu-construct { height: 100%; margin: 0.5em; box-sizing: border-box; @@ -512,7 +512,7 @@ main .top { } @media (max-height: 900px), (max-width: 1500px) { - #cryps { + #constructs { font-size: 75%; } diff --git a/client/assets/styles/styles.mobile.css b/client/assets/styles/styles.mobile.css index ededd5af..17323160 100644 --- a/client/assets/styles/styles.mobile.css +++ b/client/assets/styles/styles.mobile.css @@ -1,5 +1,5 @@ @media (max-height: 800px), (max-width: 1000px) { - #cryps { + #constructs { font-size: 8pt; padding: 0; grid-template-columns: min-content 1fr; diff --git a/client/index.html b/client/index.html index 58b3d1d7..259100d0 100644 --- a/client/index.html +++ b/client/index.html @@ -1,12 +1,12 @@ - cryps.gg - mnml pvp atbs + mnml pvp tbs - + diff --git a/client/manifest.webmanifest b/client/manifest.webmanifest index 669d4991..de265af3 100644 --- a/client/manifest.webmanifest +++ b/client/manifest.webmanifest @@ -1,7 +1,7 @@ { - "name": "cryps.gg - mnml pvp atbs", - "description": "cryps.gg - mnml pvp atbs", - "short_name": "cryps.gg", + "name": "constructs.gg - mnml pvp atbs", + "description": "constructs.gg - mnml pvp atbs", + "short_name": "constructs.gg", "icons": [ { "src": "./assets/icons/726.png", diff --git a/client/package.json b/client/package.json index a006be4f..dd03ae0c 100644 --- a/client/package.json +++ b/client/package.json @@ -1,5 +1,5 @@ { - "name": "cryps-client", + "name": "mnml-client", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 9fc79bff..9e8e1b43 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -1,5 +1,5 @@ export const setAccount = value => ({ type: 'SET_ACCOUNT', value }); -export const setCryps = value => ({ type: 'SET_CRYPS', value }); +export const setConstructs = value => ({ type: 'SET_CONSTRUCTS', value }); export const setItemInfo = value => ({ type: 'SET_ITEM_INFO', value }); export const setSkip = value => ({ type: 'SET_SKIP', value }); export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value }); @@ -11,9 +11,9 @@ export const setGame = value => ({ type: 'SET_GAME', value }); export const setResolution = value => ({ type: 'SET_RESOLUTION', value }); export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value }); export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(value) }); -export const setTeam = value => ({ type: 'SET_SELECTED_CRYPS', value: Array.from(value) }); -export const setActiveSkill = (crypId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: crypId ? { crypId, skill } : null }); -export const setActiveCryp = value => ({ type: 'SET_ACTIVE_CRYP', value }); +export const setTeam = value => ({ type: 'SET_SELECTED_CONSTRUCTS', value: Array.from(value) }); +export const setActiveSkill = (constructId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: constructId ? { constructId, skill } : null }); +export const setActiveConstruct = value => ({ type: 'SET_ACTIVE_CONSTRUCT', value }); export const setActiveItem = value => ({ type: 'SET_ACTIVE_VAR', value }); export const setInfo = value => ({ type: 'SET_INFO', value }); export const setItemEquip = value => ({ type: 'SET_ITEM_EQUIP', value }); diff --git a/client/src/app.jsx b/client/src/app.jsx index a55e8647..60a58a4c 100644 --- a/client/src/app.jsx +++ b/client/src/app.jsx @@ -28,8 +28,8 @@ document.fonts.load('16pt "Jura"').then(() => { store.dispatch(actions.setWs(ws)); ws.connect(); - const Cryps = () => ( -
+ const Constructs = () => ( +
@@ -40,7 +40,7 @@ document.fonts.load('16pt "Jura"').then(() => { const App = () => ( - + ); diff --git a/client/src/components/cryp.spawn.button.jsx b/client/src/components/cryp.spawn.button.jsx index a4f0e5bb..66e6d225 100644 --- a/client/src/components/cryp.spawn.button.jsx +++ b/client/src/components/cryp.spawn.button.jsx @@ -1,6 +1,6 @@ const preact = require('preact'); -function renderSpawnButton({ account, sendCrypSpawn }) { +function renderSpawnButton({ account, sendConstructSpawn }) { let name = ''; if (!account) return
...
; @@ -13,7 +13,7 @@ function renderSpawnButton({ account, sendCrypSpawn }) { (name = e.target.value)} />
@@ -21,7 +21,7 @@ function renderSpawnButton({ account, sendCrypSpawn }) {
diff --git a/client/src/components/cryp.spawn.container.js b/client/src/components/cryp.spawn.container.js index 9b743b1b..3ba5b1cf 100644 --- a/client/src/components/cryp.spawn.container.js +++ b/client/src/components/cryp.spawn.container.js @@ -1,16 +1,16 @@ const { connect } = require('react-redux'); -const CrypSpawnButton = require('./cryp.spawn.button'); +const ConstructSpawnButton = require('./construct.spawn.button'); const addState = connect( function receiveState(state) { const { ws } = state; - function sendCrypSpawn(name) { - return ws.sendCrypSpawn(name); + function sendConstructSpawn(name) { + return ws.sendConstructSpawn(name); } - return { account: state.account, sendCrypSpawn }; + return { account: state.account, sendConstructSpawn }; } ); -module.exports = addState(CrypSpawnButton); +module.exports = addState(ConstructSpawnButton); diff --git a/client/src/components/game.component.jsx b/client/src/components/game.component.jsx index fd83df43..d332d528 100644 --- a/client/src/components/game.component.jsx +++ b/client/src/components/game.component.jsx @@ -1,7 +1,7 @@ const preact = require('preact'); -const { STATS, eventClasses, getCombatText, crypAvatar } = require('../utils'); +const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils'); const { animationDivs } = require('../animations'); -const GameCryp = require('./game.cryp'); +const GameConstruct = require('./game.construct'); function GamePanel(props) { const { @@ -10,7 +10,7 @@ function GamePanel(props) { resolution, activeSkill, setActiveSkill, - setActiveCryp, + setActiveConstruct, selectSkillTarget, sendInstanceState, sendGameReady, @@ -76,9 +76,9 @@ function GamePanel(props) { ); - function findCryp(id) { - const team = game.players.find(t => t.cryps.find(c => c.id === id)); - if (team) return team.cryps.find(c => c.id === id); + function findConstruct(id) { + const team = game.players.find(t => t.constructs.find(c => c.id === id)); + if (team) return team.constructs.find(c => c.id === id); return null; } @@ -109,39 +109,39 @@ function GamePanel(props) { ); function PlayerTeam(team) { - const cryps = team.cryps.map((c, i) => ); + const constructs = team.constructs.map((c, i) => ); return (
- {cryps} + {constructs}
); } - function OpponentCryp(cryp, i) { - const ko = cryp.green_life.value === 0 ? 'ko' : ''; - const classes = eventClasses(resolution, cryp); + function OpponentConstruct(construct, i) { + const ko = construct.green_life.value === 0 ? 'ko' : ''; + const classes = eventClasses(resolution, construct); const stats = [STATS.greenLife, STATS.redLife, STATS.blueLife].map((s, j) => (
{s.svg(`stat-icon ${s.colour}`)} -
{cryp[s.stat].value} / {cryp[s.stat].max}
+
{construct[s.stat].value} / {construct[s.stat].max}
)); - const [combatText, combatClass] = getCombatText(cryp, resolution); + const [combatText, combatClass] = getCombatText(construct, resolution); const combatTextClass = `combat-text ${combatClass}`; const combatTextEl = combatText ?
{combatText}
: null; - const effects = cryp.effects.length - ? cryp.effects.map(c =>
{c.effect} - {c.duration}T
) + const effects = construct.effects.length + ? construct.effects.map(c =>
{c.effect} - {c.duration}T
) :
 
; - const playerTeamIds = playerTeam.cryps.map(c => c.id); + const playerTeamIds = playerTeam.constructs.map(c => c.id); const targeting = game.stack - .filter(s => playerTeamIds.includes(s.source_cryp_id) && s.target_cryp_id === cryp.id) + .filter(s => playerTeamIds.includes(s.source_construct_id) && s.target_construct_id === construct.id) .map((s, i) =>

{`< ${s.skill}`}

); const anim = ( @@ -153,17 +153,17 @@ function GamePanel(props) { return (
selectSkillTarget(cryp.id)} > + onClick={() => selectSkillTarget(construct.id)} >
{stats}
-

{cryp.name}

+

{construct.name}

{effects}
{targeting}
selectSkillTarget(cryp.id)} > - {crypAvatar(cryp.name, cryp.id)} + onClick={() => selectSkillTarget(construct.id)} > + {constructAvatar(construct.name, construct.id)} {combatTextEl} {anim}
@@ -173,10 +173,10 @@ function GamePanel(props) { function OpponentTeam(team) { - const cryps = team.cryps.map(OpponentCryp); + const constructs = team.constructs.map(OpponentConstruct); return (
- {cryps} + {constructs}
); } @@ -185,7 +185,7 @@ function GamePanel(props) { function gameClick(e) { e.stopPropagation(); - setActiveCryp(null); + setActiveConstruct(null); } return ( diff --git a/client/src/components/game.container.jsx b/client/src/components/game.container.jsx index 03c421dc..50ebb468 100644 --- a/client/src/components/game.container.jsx +++ b/client/src/components/game.container.jsx @@ -13,12 +13,12 @@ const addState = connect( resolution, showLog, activeSkill, - activeCryp, + activeConstruct, } = state; - function selectSkillTarget(targetCrypId) { + function selectSkillTarget(targetConstructId) { if (activeSkill) { - return ws.sendGameSkill(game.id, activeSkill.crypId, targetCrypId, activeSkill.skill); + return ws.sendGameSkill(game.id, activeSkill.constructId, targetConstructId, activeSkill.skill); } return false; } @@ -34,7 +34,7 @@ const addState = connect( // intercept self casting skills if (activeSkill && activeSkill.skill.self_targeting) { - ws.sendGameSkill(game.id, activeSkill.crypId, null, activeSkill.skill.skill); + ws.sendGameSkill(game.id, activeSkill.constructId, null, activeSkill.skill.skill); } return { @@ -43,7 +43,7 @@ const addState = connect( account, resolution, activeSkill, - activeCryp, + activeConstruct, selectSkillTarget, sendInstanceState, sendGameReady, @@ -51,13 +51,13 @@ const addState = connect( }, function receiveDispatch(dispatch) { - function setActiveSkill(crypId, skill) { - dispatch(actions.setActiveSkill(crypId, skill)); - // particlesJS(`particles-${crypId}`, config); + function setActiveSkill(constructId, skill) { + dispatch(actions.setActiveSkill(constructId, skill)); + // particlesJS(`particles-${constructId}`, config); } - function setActiveCryp(cryp) { - dispatch(actions.setActiveCryp(cryp)); + function setActiveConstruct(construct) { + dispatch(actions.setActiveConstruct(construct)); } function quit() { @@ -73,7 +73,7 @@ const addState = connect( dispatch(actions.setSkip(true)); } - return { setActiveSkill, setActiveCryp, quit, toggleLog, skip }; + return { setActiveSkill, setActiveConstruct, quit, toggleLog, skip }; } ); diff --git a/client/src/components/game.cryp.jsx b/client/src/components/game.cryp.jsx index 89bb2305..f26f8ff3 100644 --- a/client/src/components/game.cryp.jsx +++ b/client/src/components/game.cryp.jsx @@ -3,7 +3,7 @@ const preact = require('preact'); const range = require('lodash/range'); const actions = require('../actions'); -const { STATS, eventClasses, getCombatText, crypAvatar } = require('../utils'); +const { STATS, eventClasses, getCombatText, constructAvatar } = require('../utils'); const { animationDivs } = require('../animations'); const SkillBtn = require('./skill.btn'); @@ -18,16 +18,16 @@ const addState = connect( activeSkill, } = state; - function selectSkillTarget(targetCrypId) { + function selectSkillTarget(targetConstructId) { if (activeSkill) { - return ws.sendGameSkill(game.id, activeSkill.crypId, targetCrypId, activeSkill.skill); + return ws.sendGameSkill(game.id, activeSkill.constructId, targetConstructId, activeSkill.skill); } return false; } // intercept self casting skills if (activeSkill && activeSkill.skill.self_targeting) { - ws.sendGameSkill(game.id, activeSkill.crypId, null, activeSkill.skill.skill); + ws.sendGameSkill(game.id, activeSkill.constructId, null, activeSkill.skill.skill); } return { @@ -40,48 +40,48 @@ const addState = connect( }, ); -function GameCryp(props) { +function GameConstruct(props) { const { game, account, - cryp, + construct, resolution, activeSkill, - setActiveCryp, + setActiveConstruct, selectSkillTarget, } = props; - const ko = cryp.green_life.value === 0 ? 'ko' : ''; - const classes = eventClasses(resolution, cryp); + const ko = construct.green_life.value === 0 ? 'ko' : ''; + const classes = eventClasses(resolution, construct); const skills = range(0, 3) - .map(i => ); + .map(i => ); const stats = [STATS.greenLife, STATS.redLife, STATS.blueLife].map((s, j) => { // i've seen this happen ;/ - if (cryp[s.stat].value < 0) console.warn(cryp); + if (construct[s.stat].value < 0) console.warn(construct); return
{s.svg(`stat-icon ${s.colour}`)} -
{cryp[s.stat].value} / {cryp[s.stat].max}
+
{construct[s.stat].value} / {construct[s.stat].max}
}); - const [combatText, combatClass] = getCombatText(cryp, resolution); + const [combatText, combatClass] = getCombatText(construct, resolution); const combatTextClass = `combat-text ${combatClass}`; const combatTextEl = combatText ?
{combatText}
: null; - const effects = cryp.effects.length - ? cryp.effects.map(c =>
{c.effect} - {c.duration}T
) + const effects = construct.effects.length + ? construct.effects.map(c =>
{c.effect} - {c.duration}T
) :
 
; const playerTeam = game.players.find(t => t.id === account.id); - const playerTeamIds = playerTeam.cryps.map(c => c.id); + const playerTeamIds = playerTeam.constructs.map(c => c.id); const targeting = game.stack - .filter(s => playerTeamIds.includes(s.source_cryp_id) && s.target_cryp_id === cryp.id) + .filter(s => playerTeamIds.includes(s.source_construct_id) && s.target_construct_id === construct.id) .map((s, i) =>

{`< ${s.skill}`}

); const anim = ( @@ -93,9 +93,9 @@ function GameCryp(props) { return (
+ className={`game-construct ${ko} ${classes}`} >

- {cryp.name} + {construct.name}

{skills} @@ -105,8 +105,8 @@ function GameCryp(props) {
selectSkillTarget(cryp.id)} > - {crypAvatar(cryp.name, cryp.id)} + onClick={() => selectSkillTarget(construct.id)} > + {constructAvatar(construct.name, construct.id)} {combatTextEl} {anim}
@@ -120,4 +120,4 @@ function GameCryp(props) { ); } -module.exports = addState(GameCryp); +module.exports = addState(GameConstruct); diff --git a/client/src/components/header.component.jsx b/client/src/components/header.component.jsx index 1a5077bd..1df1afc4 100644 --- a/client/src/components/header.component.jsx +++ b/client/src/components/header.component.jsx @@ -23,7 +23,7 @@ function renderHeader(args) { return (

- cryps.gg + mnml.gg

{accountStatus}
diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 2c7f2dc8..8af1fbef 100644 --- a/client/src/components/info.component.jsx +++ b/client/src/components/info.component.jsx @@ -27,10 +27,10 @@ function Info(args) { let red = 0; let blue = 0; let green = 0; - player.cryps.forEach(cryp => { - red += cryp.colours.red; - blue += cryp.colours.blue; - green += cryp.colours.green; + player.constructs.forEach(construct => { + red += construct.colours.red; + blue += construct.colours.blue; + green += construct.colours.green; }); const teamColours = { red, blue, green }; diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index e8fb641b..dff4d03c 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -3,7 +3,7 @@ const { connect } = require('react-redux'); const Vbox = require('./vbox.component'); const InfoContainer = require('./info.container'); -const InstanceCrypsContainer = require('./instance.cryps'); +const InstanceConstructsContainer = require('./instance.constructs'); const EquipmentContainer = require('./instance.equip'); const actions = require('../actions'); @@ -137,7 +137,7 @@ function Instance(args) { - + ); } diff --git a/client/src/components/instance.create.form.jsx b/client/src/components/instance.create.form.jsx index 6eefda23..77a8abfc 100644 --- a/client/src/components/instance.create.form.jsx +++ b/client/src/components/instance.create.form.jsx @@ -6,9 +6,9 @@ const addState = connect( function receiveState(state) { const { ws, team } = state; - function sendInstanceNew(sCryps, name, players) { - if (sCryps.length) { - return ws.sendInstanceNew(sCryps, name, players); + function sendInstanceNew(sConstructs, name, players) { + if (sConstructs.length) { + return ws.sendInstanceNew(sConstructs, name, players); } return false; } diff --git a/client/src/components/instance.cryps.jsx b/client/src/components/instance.cryps.jsx index 4906520c..6e86b3ee 100644 --- a/client/src/components/instance.cryps.jsx +++ b/client/src/components/instance.cryps.jsx @@ -3,24 +3,24 @@ const preact = require('preact'); const range = require('lodash/range'); const shapes = require('./shapes'); -const { SPECS, STATS, instanceCryp } = require('../utils'); +const { SPECS, STATS, instanceConstruct } = require('../utils'); const actions = require('../actions'); const addState = connect( function receiveState(state) { - const { ws, instance, account, itemInfo, itemEquip, activeCryp } = state; + const { ws, instance, account, itemInfo, itemEquip, activeConstruct } = state; const player = instance.players.find(p => p.id === account.id); function sendInstanceReady() { return ws.sendInstanceReady(instance.id); } - function sendVboxApply(crypId, i) { - return ws.sendVboxApply(instance.id, crypId, i); + function sendVboxApply(constructId, i) { + return ws.sendVboxApply(instance.id, constructId, i); } - function sendUnequip(crypId, item) { - return ws.sendVboxUnequip(instance.id, crypId, item); + function sendUnequip(constructId, item) { + return ws.sendVboxUnequip(instance.id, constructId, item); } return { @@ -31,7 +31,7 @@ const addState = connect( sendVboxApply, itemInfo, itemEquip, - activeCryp, + activeConstruct, sendUnequip, }; }, @@ -45,8 +45,8 @@ const addState = connect( dispatch(actions.setInfo(item)); } - function setActiveCryp(value) { - dispatch(actions.setActiveCryp(value)); + function setActiveConstruct(value) { + dispatch(actions.setActiveConstruct(value)); } function clearInfo() { @@ -61,19 +61,19 @@ const addState = connect( return dispatch(actions.setItemUnequip(v)); } - return { quit, clearInfo, setInfo, setActiveCryp, setItemUnequip, setItemEquip }; + return { quit, clearInfo, setInfo, setActiveConstruct, setItemUnequip, setItemEquip }; } ); -function Cryp(props) { +function Construct(props) { const { - activeCryp, + activeConstruct, itemEquip, - cryp, + construct, player, sendVboxApply, - setActiveCryp, + setActiveConstruct, setItemUnequip, setItemEquip, itemInfo, @@ -84,9 +84,9 @@ function Cryp(props) { function onClick(e) { e.stopPropagation(); e.preventDefault(); - if (itemEquip !== null) sendVboxApply(cryp.id, itemEquip); + if (itemEquip !== null) sendVboxApply(construct.id, itemEquip); setItemEquip(null); - return setActiveCryp(cryp); + return setActiveConstruct(construct); } function hoverInfo(e, info) { @@ -100,7 +100,7 @@ function Cryp(props) { const specList = itemInfo.items.filter(v => v.spec).map(v => v.item); const skills = range(0, 3).map(i => { - const skill = cryp.skills[i]; + const skill = construct.skills[i]; const s = skill ? skill.skill : (+); @@ -108,15 +108,15 @@ function Cryp(props) { function skillClick(e) { if (!skill) return false; setItemUnequip(skill.skill); - setActiveCryp(cryp); + setActiveConstruct(construct); e.stopPropagation(); return true; } function skillDblClick(e) { if (!skill) return false; - sendUnequip(cryp.id, skill.skill); - setActiveCryp(null); + sendUnequip(construct.id, skill.skill); + setActiveConstruct(null); setItemUnequip(null); e.stopPropagation(); e.preventDefault(); @@ -140,7 +140,7 @@ function Cryp(props) { }); const specs = range(0, 6).map(i => { - const s = cryp.specs[i]; + const s = construct.specs[i]; if (!s) { const equip = specList.includes(vbox.bound[itemEquip]) ? 'equip-spec' : 'gray'; @@ -155,12 +155,12 @@ function Cryp(props) { function specClick(e) { e.stopPropagation(); setItemUnequip(s); - setActiveCryp(cryp); + setActiveConstruct(construct); } function specDblClick(e) { - sendUnequip(cryp.id, s); - setActiveCryp(null); + sendUnequip(construct.id, s); + setActiveConstruct(null); setItemUnequip(null); e.stopPropagation(); e.preventDefault(); @@ -183,14 +183,14 @@ function Cryp(props) { const stats = Object.values(STATS).map(s => (
{s.svg(`stat-icon ${s.colour} stat`)} -
{cryp[s.stat].value}
+
{construct[s.stat].value}
)); - const activeId = activeCryp ? activeCryp.id : false; - const crypClass = activeId === cryp.id ? 'instance-cryp-active' : 'instance-cryp'; + const activeId = activeConstruct ? activeConstruct.id : false; + const constructClass = activeId === construct.id ? 'instance-construct-active' : 'instance-construct'; - // const cTotal = cryp.colours.red + cryp.colours.blue + cryp.colours.green; - // const colours = mapValues(cryp.colours, c => { + // const cTotal = construct.colours.red + construct.colours.blue + construct.colours.green; + // const colours = mapValues(construct.colours, c => { // if (cTotal === 0) return 245; // return Math.floor(c / cTotal * 255); // }); @@ -204,13 +204,13 @@ function Cryp(props) { // const border = { border: `${thickness(cTotal)}px solid rgba(${colours.red}, ${colours.green}, ${colours.blue}, ${alpha})` }; return ( -
- {instanceCryp(cryp.name, cryp.id)} -

{cryp.name}

-
hoverInfo(e, 'crypSkills')} > +
+ {instanceConstruct(construct.name, construct.id)} +

{construct.name}

+
hoverInfo(e, 'constructSkills')} > {skills}
-
hoverInfo(e, 'crypSpecs')} > +
hoverInfo(e, 'constructSpecs')} > {specs}
@@ -231,15 +231,15 @@ function Cryp(props) { ); } -function InstanceCryps(props) { +function InstanceConstructs(props) { const { - activeCryp, + activeConstruct, itemEquip, player, instance, // clearInfo, setInfo, - setActiveCryp, + setActiveConstruct, sendVboxApply, itemInfo, @@ -252,27 +252,27 @@ function InstanceCryps(props) { if (!player) return false; if (instance.phase === 'Lobby') return false; - const cryps = player.cryps.map((c, i) => Cryp({ - cryp: c, - activeCryp, + const constructs = player.constructs.map((c, i) => Construct({ + construct: c, + activeConstruct, itemEquip, setItemUnequip, setItemEquip, player, sendVboxApply, setInfo, - setActiveCryp, + setActiveConstruct, itemInfo, setVboxHighlight, sendUnequip, })); - const classes = `cryp-list`; + const classes = `construct-list`; return ( -
setActiveCryp(null)}> - {cryps} +
setActiveConstruct(null)}> + {constructs}
); } -module.exports = addState(InstanceCryps); +module.exports = addState(InstanceConstructs); diff --git a/client/src/components/instance.equip.jsx b/client/src/components/instance.equip.jsx index 174d8fb4..fa5f8813 100644 --- a/client/src/components/instance.equip.jsx +++ b/client/src/components/instance.equip.jsx @@ -8,14 +8,14 @@ const { convertItem, SPECS } = require('./../utils'); const addState = connect( function receiveState(state) { - const { account, activeCryp, itemInfo, info, ws, instance, itemUnequip } = state; + const { account, activeConstruct, itemInfo, info, ws, instance, itemUnequip } = state; const player = instance.players.find(p => p.id === account.id); - function sendUnequip(crypId, item) { - return ws.sendVboxUnequip(instance.id, crypId, item); + function sendUnequip(constructId, item) { + return ws.sendVboxUnequip(instance.id, constructId, item); } - return { player, itemInfo, instance, info, sendUnequip, activeCryp, itemUnequip }; + return { player, itemInfo, instance, info, sendUnequip, activeConstruct, itemUnequip }; }, function receiveDispatch(dispatch) { @@ -48,7 +48,7 @@ function Equipment(props) { itemUnequip, setItemEquip, setItemUnequip, - activeCryp, + activeConstruct, itemInfo, sendUnequip, @@ -65,7 +65,7 @@ function Equipment(props) { const isSpec = fullInfo && fullInfo.spec; function skillClick(e, i) { - if (itemUnequip && activeCryp) return false; + if (itemUnequip && activeConstruct) return false; const value = vbox.bound[i]; setItemEquip(i); return false; @@ -74,9 +74,9 @@ function Equipment(props) { function unequipClick(e) { e.stopPropagation(); if (!itemUnequip) return false; - if (!activeCryp) return false; + if (!activeConstruct) return false; setItemUnequip(null); - return sendUnequip(activeCryp.id, itemUnequip); + return sendUnequip(activeConstruct.id, itemUnequip); } function hoverInfo(e, info) { diff --git a/client/src/components/list.jsx b/client/src/components/list.jsx index de57c909..18674f30 100644 --- a/client/src/components/list.jsx +++ b/client/src/components/list.jsx @@ -7,7 +7,7 @@ const InstanceCreateForm = require('./instance.create.form'); const addState = connect( function receiveState(state) { - const { ws, cryps, team, instances, account } = state; + const { ws, constructs, team, instances, account } = state; function sendInstanceJoin(instance) { if (team.length) { @@ -26,7 +26,7 @@ const addState = connect( return { account, - cryps, + constructs, team, sendInstanceJoin, sendInstanceState, diff --git a/client/src/components/menu.component.jsx b/client/src/components/menu.component.jsx index 0356ffd3..479e0eff 100644 --- a/client/src/components/menu.component.jsx +++ b/client/src/components/menu.component.jsx @@ -3,7 +3,7 @@ const range = require('lodash/range'); const { NULL_UUID } = require('./../utils'); -const { stringSort, crypAvatar } = require('./../utils'); +const { stringSort, constructAvatar } = require('./../utils'); const SpawnButton = require('./spawn.button'); const InstanceCreateForm = require('./instance.create.form'); @@ -19,14 +19,14 @@ const COLOURS = [ function Menu(args) { const { account, - cryps, + constructs, team, setTeam, sendInstanceState, - sendPlayerMmCrypsSet, + sendPlayerMmConstructsSet, sendInstanceJoin, sendInstanceList, - sendCrypSpawn, + sendConstructSpawn, instances, } = args; @@ -61,7 +61,7 @@ function Menu(args) { // // ); @@ -88,12 +88,12 @@ function Menu(args) { ); } - function crypList() { - if (!cryps) return
; + function constructList() { + if (!constructs) return
; // redux limitation + suggested workaround // so much for dumb components - function selectCryp(id) { + function selectConstruct(id) { // remove const i = team.findIndex(sid => sid === id); if (i > -1) { @@ -108,37 +108,37 @@ function Menu(args) { return setTeam(team); } - const crypPanels = cryps.sort(idSort).map(cryp => { - const colour = team.indexOf(cryp.id); + const constructPanels = constructs.sort(idSort).map(construct => { + const colour = team.indexOf(construct.id); const selected = colour > -1; const borderColour = selected ? COLOURS[colour] : '#000000'; return (
+ key={construct.id} + className="menu-construct-ctr">
selectCryp(cryp.id)} > - {crypAvatar(cryp.name)} -

{cryp.name}

+ onClick={() => selectConstruct(construct.id)} > + {constructAvatar(construct.name)} +

{construct.name}

); }); - const spawnButtonsNum = cryps.length < 3 - ? (3 - cryps.length) + const spawnButtonsNum = constructs.length < 3 + ? (3 - constructs.length) : 1; const spawnButtons = range(spawnButtonsNum) - .map(i => sendCrypSpawn(name)} />); + .map(i => sendConstructSpawn(name)} />); return ( -
- {crypPanels} +
+ {constructPanels} {spawnButtons}
); diff --git a/client/src/components/menu.container.jsx b/client/src/components/menu.container.jsx index bd2fecc1..a43dab97 100644 --- a/client/src/components/menu.container.jsx +++ b/client/src/components/menu.container.jsx @@ -5,7 +5,7 @@ const actions = require('./../actions'); const addState = connect( function receiveState(state) { - const { ws, cryps, team, instances, account } = state; + const { ws, constructs, team, instances, account } = state; function sendInstanceJoin(instance) { if (team.length) { @@ -14,15 +14,15 @@ const addState = connect( return false; } - function sendPlayerMmCrypsSet() { + function sendPlayerMmConstructsSet() { if (team.length) { - return ws.sendPlayerMmCrypsSet(team); + return ws.sendPlayerMmConstructsSet(team); } return false; } - function sendCrypSpawn(name) { - return ws.sendCrypSpawn(name); + function sendConstructSpawn(name) { + return ws.sendConstructSpawn(name); } function sendInstanceState(instance) { @@ -35,20 +35,20 @@ const addState = connect( return { account, - cryps, + constructs, team, sendInstanceJoin, sendInstanceState, sendInstanceList, - sendCrypSpawn, - sendPlayerMmCrypsSet, + sendConstructSpawn, + sendPlayerMmConstructsSet, instances, }; }, function receiveDispatch(dispatch) { - function setTeam(crypIds) { - dispatch(actions.setTeam(crypIds)); + function setTeam(constructIds) { + dispatch(actions.setTeam(constructIds)); } return { diff --git a/client/src/components/nav.jsx b/client/src/components/nav.jsx index c06bc2d6..30a99040 100644 --- a/client/src/components/nav.jsx +++ b/client/src/components/nav.jsx @@ -15,7 +15,7 @@ const addState = connect( account, instances, team, - cryps, + constructs, game, } = state; @@ -27,7 +27,7 @@ const addState = connect( account, instances, team, - cryps, + constructs, game, sendInstanceState, }; @@ -60,7 +60,7 @@ function Nav(args) { account, sendInstanceState, team, - cryps, + constructs, instances, game, @@ -81,8 +81,8 @@ function Nav(args) { const teamElements = team.map((c, i) => { if (c) { - const cryp = cryps.find(f => f.id === c); - return ; + const construct = constructs.find(f => f.id === c); + return ; } return ; }); diff --git a/client/src/components/skill.btn.jsx b/client/src/components/skill.btn.jsx index 548a8cc1..0a1742a1 100644 --- a/client/src/components/skill.btn.jsx +++ b/client/src/components/skill.btn.jsx @@ -17,8 +17,8 @@ const addState = connect( }, function receiveDispatch(dispatch) { - function setActiveSkill(crypId, skill) { - dispatch(actions.setActiveSkill(crypId, skill)); + function setActiveSkill(constructId, skill) { + dispatch(actions.setActiveSkill(constructId, skill)); } return { setActiveSkill }; @@ -28,7 +28,7 @@ const addState = connect( function Skill(props) { const { - cryp, + construct, game, i, mobile, @@ -36,14 +36,14 @@ function Skill(props) { setActiveSkill, } = props; - const s = cryp.skills[i]; - const ko = cryp.green_life.value === 0 ? 'ko' : ''; + const s = construct.skills[i]; + const ko = construct.green_life.value === 0 ? 'ko' : ''; if (!s) { return ( ); } @@ -52,25 +52,25 @@ function Skill(props) { ? 'top' : ''; - const cdText = cryp.skills[i].cd > 0 + const cdText = construct.skills[i].cd > 0 ? `- ${s.cd}T` : ''; const highlight = activeSkill - ? activeSkill.crypId === cryp.id && activeSkill.skill === s.skill + ? activeSkill.constructId === construct.id && activeSkill.skill === s.skill : false; function onClick(e) { e.stopPropagation(); - return setActiveSkill(cryp.id, s.skill); + return setActiveSkill(construct.id, s.skill); } - const targeting = game.stack.some(stack => stack.source_cryp_id === cryp.id && stack.skill === s.skill); + const targeting = game.stack.some(stack => stack.source_construct_id === construct.id && stack.skill === s.skill); return ( '; @@ -173,7 +173,7 @@ function registerEvents(registry, events, tutorial) { function submitSpawn(instance, thisToast, button, e, inputs) { const NAME = inputs[0].value; - ws.sendCrypSpawn(NAME); + ws.sendConstructSpawn(NAME); instance.hide({ transitionOut: 'fadeOut' }, thisToast, 'button'); } @@ -184,7 +184,7 @@ function registerEvents(registry, events, tutorial) { // overlay: true, drag: false, close: true, - title: 'SPAWN CRYP', + title: 'SPAWN CONSTRUCT', position: 'center', inputs: [ [NAME_INPUT, 'change', null, true], // true to focus @@ -202,8 +202,8 @@ function registerEvents(registry, events, tutorial) { loginPrompt, setAccount, setActiveSkill, - setCryps, - setCrypList, + setConstructs, + setConstructList, setGame, setMenu, setPlayer, diff --git a/phaser-client/src/main.js b/phaser-client/src/main.js index 7a0adc64..ef2fbede 100644 --- a/phaser-client/src/main.js +++ b/phaser-client/src/main.js @@ -1,11 +1,11 @@ -const renderCryps = require('./scenes/cryps'); +const renderConstructs = require('./scenes/constructs'); const createSocket = require('./socket'); const registerEvents = require('./events'); const createTutorial = require('./tutorial'); document.fonts.load('10pt "Jura"').then(() => { - const game = renderCryps(); + const game = renderConstructs(); const tutorial = createTutorial(); const events = registerEvents(game.registry, game.events, tutorial); const ws = createSocket(events); diff --git a/phaser-client/src/scenes/combat.animations.js b/phaser-client/src/scenes/combat.animations.js index 58fae31d..7a1ef934 100644 --- a/phaser-client/src/scenes/combat.animations.js +++ b/phaser-client/src/scenes/combat.animations.js @@ -40,7 +40,7 @@ class CombatSkills extends Phaser.GameObjects.Group { } genericHeal(sourceAlly, castLocation) { - // const { sourceX, sourceY } = getCrypPosition(sourcePos, 0); + // const { sourceX, sourceY } = getConstructPosition(sourcePos, 0); const lifespan = DELAYS.ANIMATION_DURATION; const colour = randomColour(); const particles = this.scene.add.particles(colour); diff --git a/phaser-client/src/scenes/combat.cryps.js b/phaser-client/src/scenes/combat.cryps.js index 9112d2ad..6616a5b4 100644 --- a/phaser-client/src/scenes/combat.cryps.js +++ b/phaser-client/src/scenes/combat.cryps.js @@ -4,27 +4,27 @@ const StatBar = require('./elements/combat.statbar'); const { DELAYS, TEXT, POSITIONS: { COMBAT } } = require('./constants'); -const CRYP_MARGIN = COMBAT.crypMargin(); +const CONSTRUCT_MARGIN = COMBAT.constructMargin(); const TEXT_MARGIN = COMBAT.textMargin(); -const crypAvatarText = (team, iter) => { +const constructAvatarText = (team, iter) => { const nameX = COMBAT.width() * team; - const nameY = COMBAT.y() + CRYP_MARGIN * iter + COMBAT.height() * 0.07; + const nameY = COMBAT.y() + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07; const statusX = COMBAT.width() * team; - const statusY = COMBAT.y() + TEXT_MARGIN * 6 + CRYP_MARGIN * iter + COMBAT.height() * 0.07; + const statusY = COMBAT.y() + TEXT_MARGIN * 6 + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07; return { statusX, statusY, nameX, nameY }; }; -const crypEffects = (team, iter) => { - const crypEffectsX = team ? COMBAT.width() - COMBAT.width() / 6.5 : COMBAT.width() / 6.5; - const crypEffectsY = TEXT_MARGIN * 2 + CRYP_MARGIN * iter; - return { crypEffectsX, crypEffectsY }; +const constructEffects = (team, iter) => { + const constructEffectsX = team ? COMBAT.width() - COMBAT.width() / 6.5 : COMBAT.width() / 6.5; + const constructEffectsY = TEXT_MARGIN * 2 + CONSTRUCT_MARGIN * iter; + return { constructEffectsX, constructEffectsY }; }; -const crypPosition = (team, iter) => { - const crypAvatarX = team ? COMBAT.width() - COMBAT.width() / 6 : COMBAT.width() / 6; - const crypAvatarY = TEXT_MARGIN * 5 + CRYP_MARGIN * iter; - return { crypAvatarX, crypAvatarY }; +const constructPosition = (team, iter) => { + const constructAvatarX = team ? COMBAT.width() - COMBAT.width() / 6 : COMBAT.width() / 6; + const constructAvatarY = TEXT_MARGIN * 5 + CONSTRUCT_MARGIN * iter; + return { constructAvatarX, constructAvatarY }; }; @@ -32,8 +32,8 @@ class Effects extends Phaser.GameObjects.Group { constructor(scene, team, iter) { super(scene); this.scene = scene; - const { crypEffectsX, crypEffectsY } = crypEffects(team, iter); - this.x = crypEffectsX; this.y = crypEffectsY; + const { constructEffectsX, constructEffectsY } = constructEffects(team, iter); + this.x = constructEffectsX; this.y = constructEffectsY; this.effectCount = 0; } @@ -62,28 +62,28 @@ class Effects extends Phaser.GameObjects.Group { } } -class CrypImage extends Phaser.GameObjects.Image { - constructor(scene, team, iter, cryp) { +class ConstructImage extends Phaser.GameObjects.Image { + constructor(scene, team, iter, construct) { // Get coords - const { crypAvatarX, crypAvatarY } = crypPosition(team, iter); - const { statusX, statusY, nameX, nameY } = crypAvatarText(team, iter); + const { constructAvatarX, constructAvatarY } = constructPosition(team, iter); + const { statusX, statusY, nameX, nameY } = constructAvatarText(team, iter); - // Cryp display + // Construct display // const avatar = team ? 'magmar' : 'alk'; - super(scene, crypAvatarX, crypAvatarY, 'aztec', genAvatar(cryp.name)); + super(scene, constructAvatarX, constructAvatarY, 'aztec', genAvatar(construct.name)); this.setScale(0.5); if (!team) this.flipX = true; - // Save position and cryp details + // Save position and construct details this.scene = scene; this.iter = iter; this.team = team; - this.cryp = cryp; + this.construct = construct; this.state = 'deselect'; - // Add cryp name - scene.add.text(nameX, nameY, cryp.name, TEXT.NORMAL).setOrigin(team, 0); - // Add cryp stat bars + // Add construct name + scene.add.text(nameX, nameY, construct.name, TEXT.NORMAL).setOrigin(team, 0); + // Add construct stat bars this.health = scene.add.existing(new StatBar(scene, this, 'HP')); this.red_shield = scene.add.existing(new StatBar(scene, this, 'Red Shield')); this.blue_shield = scene.add.existing(new StatBar(scene, this, 'Blue Shield')); @@ -141,18 +141,18 @@ class CrypImage extends Phaser.GameObjects.Image { } } -class CombatCryps extends Phaser.Scene { +class CombatConstructs extends Phaser.Scene { constructor() { - super({ key: 'CombatCryps' }); + super({ key: 'CombatConstructs' }); } create(game) { - this.cryps = this.add.group(); + this.constructs = this.add.group(); this.phase = game.phase; this.account = this.registry.get('account'); - this.drawCryps(game); + this.drawConstructs(game); this.registry.events.on('changedata', this.updateData, this); - this.registry.set('crypStatusUpdate', false); + this.registry.set('constructStatusUpdate', false); this.teams = game.teams.length; } @@ -168,65 +168,65 @@ class CombatCryps extends Phaser.Scene { const shouldUpdate = data !== this.phase; this.phase = data; if (shouldUpdate) { - this.cryps.children.entries.forEach(c => c.clearStatus()); - this.drawCryps(this.game); + this.constructs.children.entries.forEach(c => c.clearStatus()); + this.drawConstructs(this.game); } } - if (key === 'crypStatusUpdate' && data) { - this.updateCrypStatus(data); + if (key === 'constructStatusUpdate' && data) { + this.updateConstructStatus(data); } return true; } - drawCryps(game) { - const renderCryp = (cryp, iter, team) => { + drawConstructs(game) { + const renderConstruct = (construct, iter, team) => { // Add Image Avatar Class - const crypObj = new CrypImage(this, team, iter, cryp); - this.add.existing(crypObj); - this.cryps.add(crypObj); - return crypObj; + const constructObj = new ConstructImage(this, team, iter, construct); + this.add.existing(constructObj); + this.constructs.add(constructObj); + return constructObj; }; - const renderTeam = (cryp, iter, team) => { - const crypObj = this.cryps.children.entries - .find(c => c.cryp.id === cryp.id) - || renderCryp(cryp, iter, team); - crypObj.health.val = cryp.hp.value; - crypObj.red_shield.val = cryp.red_shield.value; - crypObj.blue_shield.val = cryp.red_shield.value; + const renderTeam = (construct, iter, team) => { + const constructObj = this.constructs.children.entries + .find(c => c.construct.id === construct.id) + || renderConstruct(construct, iter, team); + constructObj.health.val = construct.hp.value; + constructObj.red_shield.val = construct.red_shield.value; + constructObj.blue_shield.val = construct.red_shield.value; - crypObj.health.drawStatBar(); - crypObj.red_shield.drawStatBar(); - crypObj.blue_shield.drawStatBar(); - crypObj.effects.update(cryp.effects); + constructObj.health.drawStatBar(); + constructObj.red_shield.drawStatBar(); + constructObj.blue_shield.drawStatBar(); + constructObj.effects.update(construct.effects); }; const allyTeam = game.teams.find(t => t.id === this.account.id); // in future there will be more than one const [enemyTeam] = game.teams.filter(t => t.id !== this.account.id); - allyTeam.cryps.forEach((cryp, i) => renderTeam(cryp, i, 0)); + allyTeam.constructs.forEach((construct, i) => renderTeam(construct, i, 0)); if (!enemyTeam) return false; - enemyTeam.cryps.forEach((cryp, i) => renderTeam(cryp, i, 1)); + enemyTeam.constructs.forEach((construct, i) => renderTeam(construct, i, 1)); return true; } - selectCryp(crypId) { - this.cryps.children.entries.forEach(c => c.deselect()); - if (crypId) this.cryps.children.entries.find(c => c.cryp.id === crypId).select(); + selectConstruct(constructId) { + this.constructs.children.entries.forEach(c => c.deselect()); + if (constructId) this.constructs.children.entries.find(c => c.construct.id === constructId).select(); } - updateCrypStatus(status) { - const sourceCryp = this.cryps.children.entries - .find(c => c.cryp.id === status.id); + updateConstructStatus(status) { + const sourceConstruct = this.constructs.children.entries + .find(c => c.construct.id === status.id); - const targetCryp = this.cryps.children.entries - .find(c => c.cryp.id === status.target); + const targetConstruct = this.constructs.children.entries + .find(c => c.construct.id === status.target); if (this.phase === 'Skill') { - sourceCryp.statusText.text = `${status.skill} on ${targetCryp.cryp.name}`; + sourceConstruct.statusText.text = `${status.skill} on ${targetConstruct.construct.name}`; } } @@ -236,4 +236,4 @@ class CombatCryps extends Phaser.Scene { } } -module.exports = CombatCryps; +module.exports = CombatConstructs; diff --git a/phaser-client/src/scenes/combat.hitbox.js b/phaser-client/src/scenes/combat.hitbox.js index 392cbc0c..868fe5ce 100644 --- a/phaser-client/src/scenes/combat.hitbox.js +++ b/phaser-client/src/scenes/combat.hitbox.js @@ -1,14 +1,14 @@ const Phaser = require('phaser'); const { POSITIONS: { COMBAT } } = require('./constants'); -const CRYP_MARGIN = COMBAT.crypMargin(); -const BOX_HEIGHT = CRYP_MARGIN * 0.8; +const CONSTRUCT_MARGIN = COMBAT.constructMargin(); +const BOX_HEIGHT = CONSTRUCT_MARGIN * 0.8; const BOX_WIDTH = COMBAT.width() * 0.2; -class CrypHitBox extends Phaser.GameObjects.Rectangle { +class ConstructHitBox extends Phaser.GameObjects.Rectangle { constructor(scene, iter, team, cback) { - const y = COMBAT.y() + COMBAT.height() * 0.05 + CRYP_MARGIN * iter; + const y = COMBAT.y() + COMBAT.height() * 0.05 + CONSTRUCT_MARGIN * iter; super(scene, (COMBAT.width() - BOX_WIDTH) * team, y, BOX_WIDTH, BOX_HEIGHT, 0x222222); this.setOrigin(0); this.clickHandler = () => cback(); @@ -59,22 +59,22 @@ class CombatHitBox extends Phaser.Scene { skillHitBox(game) { const account = this.registry.get('account'); - const group = this.scene.get('CombatCryps').cryps; + const group = this.scene.get('CombatConstructs').constructs; const skillScene = this.scene.get('CombatSkills'); game.teams.forEach((t) => { - t.cryps.forEach((c) => { + t.constructs.forEach((c) => { const cback = () => { const { activeSkill } = skillScene; if (activeSkill) { - this.scene.get('CombatSkills').clearCrypActive(activeSkill.cryp.id); + this.scene.get('CombatSkills').clearConstructActive(activeSkill.construct.id); activeSkill.activate(); skillScene.activeSkill = null; - this.game.events.emit('SEND_SKILL', game.id, activeSkill.cryp.id, c.id, activeSkill.skill.skill); + this.game.events.emit('SEND_SKILL', game.id, activeSkill.construct.id, c.id, activeSkill.skill.skill); } }; - const crypSpawn = group.children.entries.find(s => s.cryp.id === c.id); + const constructSpawn = group.children.entries.find(s => s.construct.id === c.id); const team = c.account === account.id ? 0 : 1; - if (crypSpawn) this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback)); + if (constructSpawn) this.add.existing(new ConstructHitBox(this, constructSpawn.iter, team, cback)); }); }); this.scene.moveBelow('Combat'); diff --git a/phaser-client/src/scenes/combat.js b/phaser-client/src/scenes/combat.js index dd8a39a9..1c520c60 100644 --- a/phaser-client/src/scenes/combat.js +++ b/phaser-client/src/scenes/combat.js @@ -3,7 +3,7 @@ const { throttle } = require('lodash'); const { TEXT, POSITIONS: { COMBAT } } = require('./constants'); const CombatLog = require('./combat.log'); -const CombatCryps = require('./combat.cryps'); +const CombatConstructs = require('./combat.constructs'); const CombatSkills = require('./combat.skills'); const CombatHitBox = require('./combat.hitbox'); @@ -47,7 +47,7 @@ class Combat extends Phaser.Scene { } startGame(game) { - this.scene.manager.add('CombatCryps', CombatCryps, true, game); + this.scene.manager.add('CombatConstructs', CombatConstructs, true, game); this.scene.manager.add('CombatLog', CombatLog, true, game); this.renderedResolves = game.resolved.length; // In case you rejoin mid way this.scene.manager.add('CombatSkills', CombatSkills, true, game.phase); @@ -79,7 +79,7 @@ class Combat extends Phaser.Scene { } checkAnimation(game) { - // Check cryps are loaded and whether game is animating + // Check constructs are loaded and whether game is animating const cantAnimate = this.registry.get('gamePhase') === 'animating'; if (cantAnimate) return false; if (game.resolved.length !== this.renderedResolves) { @@ -125,7 +125,7 @@ class Combat extends Phaser.Scene { this.registry.set('menu', true); this.registry.set('game', null); - const ACTIVE_SCENES = ['CombatLog', 'CombatCryps', 'CombatSkills', 'CombatHitBox']; + const ACTIVE_SCENES = ['CombatLog', 'CombatConstructs', 'CombatSkills', 'CombatHitBox']; ACTIVE_SCENES.forEach((sKey) => { if (this.scene.get(sKey)) this.scene.get(sKey).cleanUp(); }); diff --git a/phaser-client/src/scenes/combat.render.resolutions.js b/phaser-client/src/scenes/combat.render.resolutions.js index 5ab6918d..77ceed62 100644 --- a/phaser-client/src/scenes/combat.render.resolutions.js +++ b/phaser-client/src/scenes/combat.render.resolutions.js @@ -6,23 +6,23 @@ const { POSITIONS: { COMBAT }, } = require('./constants'); -function findResolutionCryps(scene, group, resolution, game) { - const sourceSpawn = group.children.entries.find(c => c.cryp.id === resolution.source.id); +function findResolutionConstructs(scene, group, resolution, game) { + const sourceSpawn = group.children.entries.find(c => c.construct.id === resolution.source.id); -/* const sourceCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.source_cryp_id)) - .cryps.find(c => c.id === resolution.source_cryp_id); +/* const sourceConstruct = game.teams.find(t => t.constructs.find(c => c.id === resolution.source_construct_id)) + .constructs.find(c => c.id === resolution.source_construct_id); - const targetCryp = game.teams.find(t => t.cryps.find(c => c.id === resolution.target_cryp_id)) - .cryps.find(c => c.id === resolution.target_cryp_id); + const targetConstruct = game.teams.find(t => t.constructs.find(c => c.id === resolution.target_construct_id)) + .constructs.find(c => c.id === resolution.target_construct_id); */ - const targetSpawn = group.children.entries.find(c => c.cryp.id === resolution.target.id); + const targetSpawn = group.children.entries.find(c => c.construct.id === resolution.target.id); return { sourceSpawn, targetSpawn }; } function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) { const tweenParams = (targets, centreSpot) => { - const enemy = targets.cryp.account !== account.id; + const enemy = targets.construct.account !== account.id; let x = centreSpot ? COMBAT.width() * 0.3 : targets.x; x = (enemy && centreSpot) ? x + COMBAT.width() * 0.4 : x; const y = centreSpot ? COMBAT.height() * 13.25 / 35 : targets.y; @@ -36,7 +36,7 @@ function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) { let moveSourceOrig = false; const targetOnlySkill = ['DecayTick']; if (!(targetOnlySkill.includes(skill))) { - if (sourceSpawn.cryp.account !== targetSpawn.cryp.account) { + if (sourceSpawn.construct.account !== targetSpawn.construct.account) { moveSourceBattle = tweenParams(sourceSpawn, true); moveSourceOrig = tweenParams(sourceSpawn, false); } @@ -57,12 +57,12 @@ function animatePhase(scene, game, resolution, cb) { || resolution.event[0] === 'TargetKo' || resolution.event === 'Ko') return cb(); - const group = scene.scene.get('CombatCryps').cryps; + const group = scene.scene.get('CombatConstructs').constructs; const animations = new CombatAnimations(scene); const account = scene.registry.get('account'); - // Find cryps, targets - const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game); + // Find constructs, targets + const { sourceSpawn, targetSpawn } = findResolutionConstructs(scene, group, resolution, game); const { moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig, } = calculateTweenParams(sourceSpawn, targetSpawn, account, resolution.event[1].skill); @@ -74,16 +74,16 @@ function animatePhase(scene, game, resolution, cb) { }; const castLocation = castParams(); - // Move cryps into position + // Move constructs into position if (moveSourceBattle) scene.tweens.add(moveSourceBattle); scene.tweens.add(moveTargetBattle); return scene.time.delayedCall(MOVE_CREEP, () => { - const sourceAlly = sourceSpawn.cryp.account === account.id; - const targetAlly = targetSpawn.cryp.account === account.id; + const sourceAlly = sourceSpawn.construct.account === account.id; + const targetAlly = targetSpawn.construct.account === account.id; // animate animation animations.getSkill(resolution.event[1].skill, sourceAlly, targetAlly, castLocation); - // Target cryp takes damage + // Target construct takes damage scene.time.delayedCall(ANIMATION_DURATION, () => { console.log(resolution); if (resolution.event[0] === 'Damage') { diff --git a/phaser-client/src/scenes/combat.skills.js b/phaser-client/src/scenes/combat.skills.js index b65afa4b..7b0ac765 100644 --- a/phaser-client/src/scenes/combat.skills.js +++ b/phaser-client/src/scenes/combat.skills.js @@ -2,18 +2,18 @@ const Phaser = require('phaser'); const { TEXT, POSITIONS: { COMBAT } } = require('./constants'); -const CRYP_KEY_MAP = ['keydown_ONE', 'keydown_TWO', 'keydown_THREE']; +const CONSTRUCT_KEY_MAP = ['keydown_ONE', 'keydown_TWO', 'keydown_THREE']; const SKILL_KEY_MAP = ['keydown_Q', 'keydown_W', 'keydown_E', 'keydown_R']; const TARGET_KEY_MAP = ['keydown_SEVEN', 'keydown_EIGHT', 'keydown_NINE', 'keydown_ZERO']; -const CRYP_MARGIN = COMBAT.crypMargin(); +const CONSTRUCT_MARGIN = COMBAT.constructMargin(); const TEXT_MARGIN = COMBAT.textMargin(); const SKILL_WIDTH = COMBAT.width() / 10; const SKILL_HEIGHT = COMBAT.height() / 30; -const skillPosition = (crypIter, skillIter) => { +const skillPosition = (constructIter, skillIter) => { const skillTextX = COMBAT.width() / 3.8; - const skillTextY = (TEXT_MARGIN * skillIter) * 1.5 + CRYP_MARGIN * crypIter + COMBAT.y() + COMBAT.height() * 0.07; + const skillTextY = (TEXT_MARGIN * skillIter) * 1.5 + CONSTRUCT_MARGIN * constructIter + COMBAT.y() + COMBAT.height() * 0.07; return [skillTextX, skillTextY]; }; @@ -28,9 +28,9 @@ const skillCheckHitBox = (scenePlugin, pointer) => { return false; }; -class CrypSkill extends Phaser.GameObjects.Container { - constructor(scene, x, y, skill, cryp) { - // Avatar will be a property of cryp +class ConstructSkill extends Phaser.GameObjects.Container { + constructor(scene, x, y, skill, construct) { + // Avatar will be a property of construct super(scene, x, y); const CD_TEXT = skill.cd ? `(${skill.cd}T)` : ''; const SKILL_TEXT = `${skill.skill} ${CD_TEXT}`; @@ -42,7 +42,7 @@ class CrypSkill extends Phaser.GameObjects.Container { this.add(this.skillText); this.state = 'deselect'; - this.cryp = cryp; + this.construct = construct; this.skill = skill; this.scene = scene; @@ -117,7 +117,7 @@ class CombatSkills extends Phaser.Scene { if (key === 'gamePhase' && data) { const shouldUpdate = data !== this.phase; if (shouldUpdate) { - this.scene.get('CombatCryps').selectCryp(null); + this.scene.get('CombatConstructs').selectConstruct(null); return this.scene.restart(data); } return false; @@ -135,9 +135,9 @@ class CombatSkills extends Phaser.Scene { const { keyboard } = this.input; const { events } = this.game; - const addSkill = (i, j, skill, cryp) => { + const addSkill = (i, j, skill, construct) => { const skillTextPos = skillPosition(i, j); - const skillObj = new CrypSkill(this, skillTextPos[0], skillTextPos[1], skill, cryp); + const skillObj = new ConstructSkill(this, skillTextPos[0], skillTextPos[1], skill, construct); if (skill.cd) { skillObj.skillBox.setFillStyle(0x9d9ea0); } else { @@ -150,22 +150,22 @@ class CombatSkills extends Phaser.Scene { const team = game.teams.find(t => t.id === account.id); const enemyTeam = game.teams.find(t => t.id !== account.id); - team.cryps.forEach((cryp) => { + team.constructs.forEach((construct) => { // return early if KOd - if (cryp.hp.value === 0) return true; + if (construct.hp.value === 0) return true; - // find the cryp position - const { iter } = this.scene.get('CombatCryps').cryps.children.entries.find(c => c.cryp.id === cryp.id); + // find the construct position + const { iter } = this.scene.get('CombatConstructs').constructs.children.entries.find(c => c.construct.id === construct.id); // draw the skills - const skillButtons = cryp.skills.map((skill, j) => addSkill(iter, j, skill, cryp)); + const skillButtons = construct.skills.map((skill, j) => addSkill(iter, j, skill, construct)); - const bindCrypKeys = () => this.mapSkillKeys(skillButtons, game.id, cryp.id, team.id, enemyTeam.id, iter); + const bindConstructKeys = () => this.mapSkillKeys(skillButtons, game.id, construct.id, team.id, enemyTeam.id, iter); // reset everything - keyboard.on('keydown_ESC', bindCrypKeys, this); - events.on('SEND_SKILL', bindCrypKeys, this); - bindCrypKeys(); + keyboard.on('keydown_ESC', bindConstructKeys, this); + events.on('SEND_SKILL', bindConstructKeys, this); + bindConstructKeys(); return true; }); @@ -174,16 +174,16 @@ class CombatSkills extends Phaser.Scene { } // FIXME - // needs to send crypId not team - mapSkillKeys(skillButtons, gameId, crypId, alliesId, enemyId, i) { + // needs to send constructId not team + mapSkillKeys(skillButtons, gameId, constructId, alliesId, enemyId, i) { const { keyboard } = this.input; - keyboard.removeListener(CRYP_KEY_MAP[i]); + keyboard.removeListener(CONSTRUCT_KEY_MAP[i]); - keyboard.on(CRYP_KEY_MAP[i], () => { + keyboard.on(CONSTRUCT_KEY_MAP[i], () => { SKILL_KEY_MAP.forEach(k => keyboard.removeListener(k)); - this.scene.get('CombatCryps').selectCryp(crypId); + this.scene.get('CombatConstructs').selectConstruct(constructId); skillButtons.forEach((button, j) => { keyboard.on(SKILL_KEY_MAP[j], () => { @@ -191,21 +191,21 @@ class CombatSkills extends Phaser.Scene { button.select(); // clear existing keys - CRYP_KEY_MAP.forEach(k => keyboard.removeListener(k)); + CONSTRUCT_KEY_MAP.forEach(k => keyboard.removeListener(k)); TARGET_KEY_MAP.forEach(k => keyboard.removeListener(k)); - CRYP_KEY_MAP.forEach(k => keyboard.on(k, () => { - this.clearCrypActive(crypId); + CONSTRUCT_KEY_MAP.forEach(k => keyboard.on(k, () => { + this.clearConstructActive(constructId); button.activate(); this.activeSkill = null; - this.game.events.emit('SEND_SKILL', gameId, crypId, alliesId, button.skill.skill); + this.game.events.emit('SEND_SKILL', gameId, constructId, alliesId, button.skill.skill); })); TARGET_KEY_MAP.forEach(k => keyboard.on(k, () => { - this.clearCrypActive(crypId); + this.clearConstructActive(constructId); button.activate(); this.activeSkill = null; - this.game.events.emit('SEND_SKILL', gameId, crypId, enemyId, button.skill.skill); + this.game.events.emit('SEND_SKILL', gameId, constructId, enemyId, button.skill.skill); })); }, this); }); @@ -214,15 +214,15 @@ class CombatSkills extends Phaser.Scene { return true; } - clearCrypActive(crypId) { + clearConstructActive(constructId) { this.scene.scene.children.list.forEach((s) => { - if (s.cryp.id === crypId && s.state === 'activate') s.deselect(); + if (s.construct.id === constructId && s.state === 'activate') s.deselect(); }); } clearKeys() { TARGET_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); - CRYP_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); + CONSTRUCT_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); SKILL_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); } diff --git a/phaser-client/src/scenes/constants.js b/phaser-client/src/scenes/constants.js index 8c48cf3b..ffe0b475 100644 --- a/phaser-client/src/scenes/constants.js +++ b/phaser-client/src/scenes/constants.js @@ -7,10 +7,10 @@ const CANVAS_HEIGHT = () => Math.floor(window.innerHeight); const headerWidth = () => CANVAS_WIDTH(); const headerHeight = () => Math.floor(CANVAS_HEIGHT() * 0.05); -const menuCrypListWidth = () => Math.floor(CANVAS_WIDTH() * 0.3); -const menuCrypListHeight = () => Math.floor(CANVAS_HEIGHT() - headerHeight()); -const menuCrypListX = () => Math.floor(CANVAS_WIDTH() * 0.3); -const menuCrypListY = () => headerHeight(); +const menuConstructListWidth = () => Math.floor(CANVAS_WIDTH() * 0.3); +const menuConstructListHeight = () => Math.floor(CANVAS_HEIGHT() - headerHeight()); +const menuConstructListX = () => Math.floor(CANVAS_WIDTH() * 0.3); +const menuConstructListY = () => headerHeight(); const itemListWidth = () => Math.floor(CANVAS_WIDTH() * 0.5); const itemListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.95); @@ -38,13 +38,13 @@ const combatWidth = () => CANVAS_WIDTH(); const combatHeight = () => CANVAS_HEIGHT() - headerHeight(); const combatY = () => headerHeight(); const combatX = () => 0; -const combatCrypMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 4.5); +const combatConstructMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 4.5); const combatTextMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 35); -const statsWidth = () => Math.floor(CANVAS_WIDTH() - menuCrypListWidth()); +const statsWidth = () => Math.floor(CANVAS_WIDTH() - menuConstructListWidth()); const statsHeight = () => CANVAS_HEIGHT() - headerHeight(); const statsY = () => headerHeight(); -const statsX = () => menuCrypListWidth(); +const statsX = () => menuConstructListWidth(); const statsKnownX = () => Math.floor(statsX() + statsWidth() / 4); const statsLearnableX = () => Math.floor(statsX() + statsWidth() / 2); const statsTextMargin = () => 24; @@ -70,11 +70,11 @@ module.exports = { height: headerHeight, }, - CRYP_LIST: { - x: menuCrypListX, - y: menuCrypListY, - width: menuCrypListWidth, - height: menuCrypListHeight, + CONSTRUCT_LIST: { + x: menuConstructListX, + y: menuConstructListY, + width: menuConstructListWidth, + height: menuConstructListHeight, }, MENU_MAIN: { @@ -127,7 +127,7 @@ module.exports = { y: combatY, width: combatWidth, height: combatHeight, - crypMargin: combatCrypMargin, + constructMargin: combatConstructMargin, textMargin: combatTextMargin, @@ -172,7 +172,7 @@ module.exports = { ITEMS: { SKILLS: { Amplify: { - description: 'increase the magic damage dealt by a cryp', + description: 'increase the magic damage dealt by a construct', colours: '1 Green 1 Blue', }, @@ -182,7 +182,7 @@ module.exports = { }, Banish: { - description: 'target cryp is prevented from casting any skills and taking any damage', + description: 'target construct is prevented from casting any skills and taking any damage', colours: '1 Red 1 Green', }, @@ -198,7 +198,7 @@ module.exports = { }, Buff: { - description: 'increase target cryp speed', + description: 'increase target construct speed', upgrades: 'combine with 2 red / blue / green', }, @@ -213,42 +213,42 @@ module.exports = { }, Curse: { - description: 'target cryp takes increased magic damage', + description: 'target construct takes increased magic damage', colours: '2 Blue', }, Debuff: { - description: 'reduce target cryp speed', + description: 'reduce target construct speed', upgrades: 'combine with 2 red / blue / green', }, Decay: { - description: 'afflict a cryp with a blue damage based damage over time debuff', + description: 'afflict a construct with a blue damage based damage over time debuff', colours: '1 Green 1 Blue', }, Empower: { - description: 'increase the red damage dealt by a cryp', + description: 'increase the red damage dealt by a construct', colours: '2 Red', }, Haste: { - description: 'magical skill that increases speed of target cryp', + description: 'magical skill that increases speed of target construct', colours: '1 Red 1 Blue', }, Heal: { - description: 'heal a cryp with blue damage', + description: 'heal a construct with blue damage', colours: '2 Green', }, Hex: { - description: 'magical bsed skill that prevents target cryp from using any skills', + description: 'magical bsed skill that prevents target construct from using any skills', colours: '1 Red 1 Blue', }, Hostility: { - description: 'magical bsed skill that prevents target cryp from using any skills', + description: 'magical bsed skill that prevents target construct from using any skills', colours: '2 Blue', }, @@ -263,12 +263,12 @@ module.exports = { }, Purge: { - description: 'remove magical buffs from target cryp', + description: 'remove magical buffs from target construct', colours: '2 Green', }, Purify: { - description: 'remove magical debuffs from target cryp', + description: 'remove magical debuffs from target construct', colours: '1 Red 1 Green', }, @@ -292,17 +292,17 @@ module.exports = { }, Shield: { - description: 'grants immunity to magical skills to target cryp', + description: 'grants immunity to magical skills to target construct', colours: '1 Green 1 Blue', }, Silence: { - description: 'prevent target cryp from casting magical skills', + description: 'prevent target construct from casting magical skills', colours: '1 Green 1 Blue', }, Siphon: { - description: 'siphon hp from target cryp with a blue damage based debuff', + description: 'siphon hp from target construct with a blue damage based debuff', colours: '1 Green 1 Blue', }, @@ -311,7 +311,7 @@ module.exports = { }, Slow: { - description: 'magical skill that reduces speed of target cryp', + description: 'magical skill that reduces speed of target construct', colours: '1 Red 1 Green', }, @@ -331,13 +331,13 @@ module.exports = { }, Stun: { - description: 'red skill hat prevents target cryp from using any skills', + description: 'red skill hat prevents target construct from using any skills', upgrades: 'combine with 2 red / blue / green', }, Taunt: { - description: 'Enemy skills will prioritise cryps with this skill active', + description: 'Enemy skills will prioritise constructs with this skill active', colours: '1 Red 1 Green', }, @@ -354,19 +354,19 @@ module.exports = { SPECS: { Damage: { - description: 'Increase red / green / blue power stats cryp', + description: 'Increase red / green / blue power stats construct', upgrades: 'combine with 2 red / blue / green', }, Hp: { - description: 'Increases health of cryp', + description: 'Increases health of construct', upgrades: 'combine with 2 red / blue / green', }, Speed: { - description: 'Increases speed of cryp', + description: 'Increases speed of construct', upgrades: 'combine with 2 red / blue / green', }, }, diff --git a/phaser-client/src/scenes/cryps.js b/phaser-client/src/scenes/cryps.js index b63c0512..c1fd95e9 100644 --- a/phaser-client/src/scenes/cryps.js +++ b/phaser-client/src/scenes/cryps.js @@ -7,7 +7,7 @@ const Combat = require('./combat'); // const Background = require('./background'); -function renderCryps() { +function renderConstructs() { const config = { type: Phaser.CANVAS, // backgroundColor: '#181818', @@ -74,4 +74,4 @@ function renderCryps() { return game; } -module.exports = renderCryps; +module.exports = renderConstructs; diff --git a/phaser-client/src/scenes/elements/combat.statbar.js b/phaser-client/src/scenes/elements/combat.statbar.js index 7189e945..c85d10a1 100644 --- a/phaser-client/src/scenes/elements/combat.statbar.js +++ b/phaser-client/src/scenes/elements/combat.statbar.js @@ -1,49 +1,49 @@ const Phaser = require('phaser'); const { TEXT, POSITIONS: { COMBAT }, COLOURS } = require('.././constants'); -const CRYP_MARGIN = COMBAT.crypMargin(); +const CONSTRUCT_MARGIN = COMBAT.constructMargin(); const TEXT_MARGIN = COMBAT.textMargin(); const statBarDimensions = (team, iter, margin) => { const statBarWidth = COMBAT.width() * 0.07; const statBarHeight = TEXT_MARGIN / 1.5; const statBarX = (COMBAT.width() - statBarWidth) * team; - const statBarY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CRYP_MARGIN * iter + COMBAT.height() * 0.07; + const statBarY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07; return { statBarX, statBarY, statBarWidth, statBarHeight }; }; const statTextCoord = (team, iter, margin) => { const statTextX = team ? COMBAT.width() - COMBAT.width() * 0.075 : COMBAT.width() * 0.075; - const statTextY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CRYP_MARGIN * iter + COMBAT.height() * 0.07; + const statTextY = COMBAT.y() + TEXT_MARGIN * (margin + 1) + CONSTRUCT_MARGIN * iter + COMBAT.height() * 0.07; return { statTextX, statTextY }; }; class StatBar extends Phaser.GameObjects.Graphics { - constructor(scene, cryp, type) { + constructor(scene, construct, type) { super(scene); - this.crypObj = cryp; + this.constructObj = construct; this.type = type; if (type === 'HP') { - this.val = this.crypObj.cryp.hp.value; - this.max = this.crypObj.cryp.hp.max; + this.val = this.constructObj.construct.hp.value; + this.max = this.constructObj.construct.hp.max; this.margin = 0; } else if (type === 'Red Shield') { - this.val = this.crypObj.cryp.red_shield.value; - this.max = this.crypObj.cryp.red_shield.max; + this.val = this.constructObj.construct.red_shield.value; + this.max = this.constructObj.construct.red_shield.max; this.margin = 1; } else if (type === 'Blue Shield') { - this.val = this.crypObj.cryp.blue_shield.value; - this.max = this.crypObj.cryp.blue_shield.max; + this.val = this.constructObj.construct.blue_shield.value; + this.max = this.constructObj.construct.blue_shield.max; this.margin = 2; } else if (type === 'Evasion') { - this.val = this.crypObj.cryp.evasion.value; - this.max = this.crypObj.cryp.evasion.max; + this.val = this.constructObj.construct.evasion.value; + this.max = this.constructObj.construct.evasion.max; this.margin = 3; } - const { statTextX, statTextY } = statTextCoord(cryp.team, cryp.iter, this.margin); - this.statText = scene.add.text(statTextX, statTextY, '', TEXT.NORMAL).setOrigin(cryp.team, 0); + const { statTextX, statTextY } = statTextCoord(construct.team, construct.iter, this.margin); + this.statText = scene.add.text(statTextX, statTextY, '', TEXT.NORMAL).setOrigin(construct.team, 0); this.drawStatBar(); } @@ -51,7 +51,7 @@ class StatBar extends Phaser.GameObjects.Graphics { this.clear(); const { statBarX, statBarY, statBarWidth, statBarHeight, - } = statBarDimensions(this.crypObj.team, this.crypObj.iter, this.margin); + } = statBarDimensions(this.constructObj.team, this.constructObj.iter, this.margin); this.statText.text = `${this.val.toString()} / ${this.max.toString()} ${this.type}`; // Draw Black Border this.fillStyle(COLOURS.BLACK); @@ -78,7 +78,7 @@ class StatBar extends Phaser.GameObjects.Graphics { } else { this.val = (this.val - value > this.max) ? this.max : this.val -= value; } - if (this.val === 0 && this.type === 'HP') this.crypObj.setKo(); + if (this.val === 0 && this.type === 'HP') this.constructObj.setKo(); this.drawStatBar(); } } diff --git a/phaser-client/src/scenes/game.list.js b/phaser-client/src/scenes/game.list.js index cdb16b06..d436770b 100644 --- a/phaser-client/src/scenes/game.list.js +++ b/phaser-client/src/scenes/game.list.js @@ -27,15 +27,15 @@ class GameList extends Phaser.Scene { .setInteractive() .setOrigin(0); - const TITLE = `${game.teams[0].cryps.map(c => c.name).join(', ')} - ${game.team_size}v${game.team_size}`; + const TITLE = `${game.teams[0].constructs.map(c => c.name).join(', ')} - ${game.team_size}v${game.team_size}`; this.add .text(gameBox.getCenter().x, gameBox.getCenter().y, TITLE, TEXT.NORMAL) .setOrigin(0.5, 0.5); gameBox.on('pointerdown', () => { - const cryps = this.registry.get('cryps'); - const team = cryps.filter(c => c.active).map(c => c.id); + const constructs = this.registry.get('constructs'); + const team = constructs.filter(c => c.active).map(c => c.id); ws.sendGameJoin(game.id, team); }); }; diff --git a/phaser-client/src/scenes/header.js b/phaser-client/src/scenes/header.js index f2cd78e3..c6c31c05 100644 --- a/phaser-client/src/scenes/header.js +++ b/phaser-client/src/scenes/header.js @@ -20,7 +20,7 @@ class Header extends Phaser.Scene { } create() { - this.add.text(0, 0, 'cryps.gg', TEXT.HEADER); + this.add.text(0, 0, 'constructs.gg', TEXT.HEADER); } } diff --git a/phaser-client/src/scenes/home.cryps.js b/phaser-client/src/scenes/home.cryps.js index f112dba1..c0620d11 100644 --- a/phaser-client/src/scenes/home.cryps.js +++ b/phaser-client/src/scenes/home.cryps.js @@ -1,14 +1,14 @@ const Phaser = require('phaser'); const { remove } = require('lodash'); -const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants'); +const { TEXT, COLOURS, POSITIONS: { CONSTRUCT_LIST } } = require('./constants'); const genAvatar = require('./avatar'); const { LineGroup, LineBox } = require('./elements/outline.rotate'); -const ROW_HEIGHT = CRYP_LIST.height() * 0.1; -const ROW_WIDTH = CRYP_LIST.width(); +const ROW_HEIGHT = CONSTRUCT_LIST.height() * 0.1; +const ROW_WIDTH = CONSTRUCT_LIST.width(); -const menuY = CRYP_LIST.height() * 0.8; +const menuY = CONSTRUCT_LIST.height() * 0.8; const KEY_MAP = [ 'keydown-ONE', @@ -18,41 +18,41 @@ const KEY_MAP = [ const NULL_UUID = '00000000-0000-0000-0000-000000000000'; -class HomeCrypList extends Phaser.Scene { +class HomeConstructList extends Phaser.Scene { constructor() { - super({ key: 'HomeCryps' }); + super({ key: 'HomeConstructs' }); } updateData(parent, key, data) { - if (key === 'crypList') { + if (key === 'constructList') { KEY_MAP.forEach(k => this.input.keyboard.removeListener(k)); this.scene.restart(); } } create() { - // this.cameras.main.setViewport(CRYP_LIST.x(), CRYP_LIST.y(), CRYP_LIST.width(), CRYP_LIST.height()); + // this.cameras.main.setViewport(CONSTRUCT_LIST.x(), CONSTRUCT_LIST.y(), CONSTRUCT_LIST.width(), CONSTRUCT_LIST.height()); this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this); - const cryps = this.registry.get('crypList'); + const constructs = this.registry.get('constructList'); const lineGroup = this.add.existing(new LineGroup(this)); - if (!cryps) return true; + if (!constructs) return true; const ws = this.registry.get('ws'); - this.activeCryps = []; - // We only display 3 cryps others can be viewed in cryp list (soon TM) - for (let i = 0; i < cryps.length; i += 1) { - const cryp = cryps[i]; + this.activeConstructs = []; + // We only display 3 constructs others can be viewed in construct list (soon TM) + for (let i = 0; i < constructs.length; i += 1) { + const construct = constructs[i]; const BOX_WIDTH = Math.floor(ROW_WIDTH / 5); const ROW_X = BOX_WIDTH * 2 * (i % 3); - const ROW_Y = CRYP_LIST.y() + (Math.floor(i / 3)) * ROW_HEIGHT * 1.5; + const ROW_Y = CONSTRUCT_LIST.y() + (Math.floor(i / 3)) * ROW_HEIGHT * 1.5; const ACTIVE_FILL = 0.2; const FILL = Object.values(COLOURS)[i]; - // Selection of cryps + // Selection of constructs - // Cryp avatar and interaction box + // Construct avatar and interaction box const cReady = this.add .rectangle(ROW_X, ROW_Y + ROW_HEIGHT * 0.2, BOX_WIDTH * 2, ROW_HEIGHT, FILL) .setInteractive() @@ -60,11 +60,11 @@ class HomeCrypList extends Phaser.Scene { cReady.setAlpha(0.2); cReady.on('pointerdown', () => { lineGroup.clear(true, true); - if (this.activeCryps.includes(cReady)) { - remove(this.activeCryps, n => n === cReady); + if (this.activeConstructs.includes(cReady)) { + remove(this.activeConstructs, n => n === cReady); cReady.setAlpha(0.2); } else { - this.activeCryps.push(cReady); + this.activeConstructs.push(cReady); cReady.setAlpha(0.75); lineGroup.add(this.add.existing( new LineBox(this, cReady.x, cReady.y, cReady.width, cReady.height, cReady.fillColor, 3) @@ -79,24 +79,24 @@ class HomeCrypList extends Phaser.Scene { cReady.setFillStyle(FILL, ACTIVE_FILL); }; - cReady.cryp = cryp; + cReady.construct = construct; this.add.image( cReady.getCenter().x, cReady.getCenter().y, 'aztec', - genAvatar(cryp.name) + genAvatar(construct.name) ); - this.add.text(ROW_X + BOX_WIDTH, ROW_Y, cryp.name, TEXT.HEADER) + this.add.text(ROW_X + BOX_WIDTH, ROW_Y, construct.name, TEXT.HEADER) .setOrigin(0.5, 0.5); } - // Add Spawn Cryp Option + // Add Spawn Construct Option const spawn = this.add .rectangle(ROW_WIDTH * 0.05, menuY, ROW_WIDTH * 0.2, ROW_HEIGHT * 0.5, 0x888888) .setInteractive() .setOrigin(0) .on('pointerdown', () => { - this.game.events.emit('CRYP_SPAWN'); + this.game.events.emit('CONSTRUCT_SPAWN'); }); this.add .text(spawn.getCenter().x, spawn.getCenter().y, '+', TEXT.HEADER) @@ -107,9 +107,9 @@ class HomeCrypList extends Phaser.Scene { .setInteractive() .setOrigin(0) .on('pointerdown', () => { - const playerCryps = []; - this.activeCryps.forEach(obj => playerCryps.push(obj.cryp.id)); - ws.sendPlayerCrypsSet(NULL_UUID, playerCryps); + const playerConstructs = []; + this.activeConstructs.forEach(obj => playerConstructs.push(obj.construct.id)); + ws.sendPlayerConstructsSet(NULL_UUID, playerConstructs); }); this.add .text(joinNormal.getCenter().x, joinNormal.getCenter().y, 'Join Normal', TEXT.HEADER) @@ -120,9 +120,9 @@ class HomeCrypList extends Phaser.Scene { .setInteractive() .setOrigin(0) .on('pointerdown', () => { - const playerCryps = []; - this.activeCryps.forEach(obj => playerCryps.push(obj.cryp.id)); - ws.sendInstanceJoin(playerCryps); + const playerConstructs = []; + this.activeConstructs.forEach(obj => playerConstructs.push(obj.construct.id)); + ws.sendInstanceJoin(playerConstructs); }); this.add .text(joinInstance.getCenter().x, joinInstance.getCenter().y, 'New Instance', TEXT.HEADER) @@ -139,4 +139,4 @@ class HomeCrypList extends Phaser.Scene { } } -module.exports = HomeCrypList; +module.exports = HomeConstructList; diff --git a/phaser-client/src/scenes/home.js b/phaser-client/src/scenes/home.js index 175fa4a4..fb03e009 100644 --- a/phaser-client/src/scenes/home.js +++ b/phaser-client/src/scenes/home.js @@ -1,7 +1,7 @@ const Phaser = require('phaser'); -const HomeCryps = require('./home.cryps'); +const HomeConstructs = require('./home.constructs'); const HomeNavigation = require('./home.navigation'); const HomeRankings = require('./home.rankings'); @@ -10,7 +10,7 @@ const HomeShop = require('./home.shop'); const HomeInstances = require('./home.instances'); const FIXED_SCENES = [ - 'HomeCryps', + 'HomeConstructs', 'HomeNavigation', ]; @@ -31,7 +31,7 @@ class Home extends Phaser.Scene { this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this); - this.scene.manager.add('HomeCryps', HomeCryps, true); + this.scene.manager.add('HomeConstructs', HomeConstructs, true); this.scene.manager.add('HomeNavigation', HomeNavigation, true); diff --git a/phaser-client/src/scenes/item.info.js b/phaser-client/src/scenes/item.info.js index 077e4c6e..0e116ae3 100644 --- a/phaser-client/src/scenes/item.info.js +++ b/phaser-client/src/scenes/item.info.js @@ -16,7 +16,7 @@ class ItemInfo extends Phaser.Scene { } create(props) { - const { item, cryp } = props; + const { item, construct } = props; if (!item) return false; // Default item text @@ -51,19 +51,19 @@ class ItemInfo extends Phaser.Scene { .setWordWrapWidth(WIDTH * 0.75); if (colours !== '') { this.add - .text(X, Y + HEIGHT * 0.35, `Adds ${colours} to cryp`, TEXT.NORMAL) + .text(X, Y + HEIGHT * 0.35, `Adds ${colours} to construct`, TEXT.NORMAL) .setWordWrapWidth(WIDTH * 0.75); } - if (!cryp) return true; + if (!construct) return true; const ws = this.registry.get('ws'); const { vbox } = this.registry.get('player'); const unEquip = this.add.rectangle(X, UNEQUIP_Y, UNEQUIP_WIDTH, UNEQUIP_HEIGHT, 0x222222) .setOrigin(0, 0) .setInteractive() .on('pointerdown', () => { - ws.sendVboxUnequip(vbox.instance, cryp.id, item); - this.registry.set('crypStats', cryp); + ws.sendVboxUnequip(vbox.instance, construct.id, item); + this.registry.set('constructStats', construct); }); this.add.text(unEquip.getCenter().x, unEquip.getCenter().y, 'unequip', TEXT.HEADER) .setOrigin(0.5, 0.5); diff --git a/phaser-client/src/scenes/item.list.js b/phaser-client/src/scenes/item.list.js index c8d422b4..74758520 100644 --- a/phaser-client/src/scenes/item.list.js +++ b/phaser-client/src/scenes/item.list.js @@ -109,8 +109,8 @@ class DeleteHitBox extends Phaser.GameObjects.Rectangle { const itemCheckHitbox = (scene, pointer) => { - const { list } = scene.scene.get('MenuCrypList').children; - const hitboxes = list.filter(c => c.cryp) + const { list } = scene.scene.get('MenuConstructList').children; + const hitboxes = list.filter(c => c.construct) .concat(scene.children.list.filter(c => c instanceof CombinerHitBox || c instanceof DeleteHitBox)); let found; @@ -283,7 +283,7 @@ class ItemList extends Phaser.Scene { // Check first for hitbox interaction const hitBox = itemCheckHitbox(this, pointer); if (hitBox) { - // hitbox can only be the combinerhitbox, deletehitbox or cryp avatar + // hitbox can only be the combinerhitbox, deletehitbox or construct avatar hitBox.itemDeselect(); if (hitBox instanceof CombinerHitBox) { if (hitBox.item === item) deallocate(item); @@ -291,7 +291,7 @@ class ItemList extends Phaser.Scene { } else if (hitBox instanceof DeleteHitBox) { ws.sendVboxReclaim(vbox.instance, item.index); } else { - ws.sendVboxApply(vbox.instance, hitBox.cryp.id, item.index); + ws.sendVboxApply(vbox.instance, hitBox.construct.id, item.index); deallocate(item); } return true; } diff --git a/phaser-client/src/scenes/menu.cryps.list.js b/phaser-client/src/scenes/menu.cryps.list.js index a6e3c1ea..d5792e71 100644 --- a/phaser-client/src/scenes/menu.cryps.list.js +++ b/phaser-client/src/scenes/menu.cryps.list.js @@ -1,11 +1,11 @@ const Phaser = require('phaser'); -const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants'); +const { TEXT, COLOURS, POSITIONS: { CONSTRUCT_LIST } } = require('./constants'); const genAvatar = require('./avatar'); const Item = require('./elements/item'); -const BOX_WIDTH = Math.floor(CRYP_LIST.width()); -const BOX_HEIGHT = Math.floor(CRYP_LIST.height() / 3.34); +const BOX_WIDTH = Math.floor(CONSTRUCT_LIST.width()); +const BOX_HEIGHT = Math.floor(CONSTRUCT_LIST.height() / 3.34); const TEXT_MARGIN = 24; @@ -15,113 +15,113 @@ const KEY_MAP = [ 'keydown-THREE', ]; -class MenuCrypList extends Phaser.Scene { +class MenuConstructList extends Phaser.Scene { constructor() { - super({ key: 'MenuCrypList' }); + super({ key: 'MenuConstructList' }); } create() { this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this); const player = this.registry.get('player'); - if (player) this.drawCryps(player.cryps); + if (player) this.drawConstructs(player.constructs); } updateData(parent, key, data) { if (key === 'player') { - this.drawCryps(data.cryps); + this.drawConstructs(data.constructs); } } - drawCryps(cryps) { - if (!cryps) return true; - if (this.crypGroup) this.crypGroup.destroy(true); - this.crypGroup = this.add.group(); - const addCryp = (cryp, i) => { - const ROW_X = CRYP_LIST.x(); - const ROW_Y = CRYP_LIST.y() + BOX_HEIGHT * i * 1.1; + drawConstructs(constructs) { + if (!constructs) return true; + if (this.constructGroup) this.constructGroup.destroy(true); + this.constructGroup = this.add.group(); + const addConstruct = (construct, i) => { + const ROW_X = CONSTRUCT_LIST.x(); + const ROW_Y = CONSTRUCT_LIST.y() + BOX_HEIGHT * i * 1.1; const ACTIVE_FILL = 0.2; const FILL = Object.values(COLOURS)[i]; - // Selection of cryps + // Selection of constructs const selectFn = () => { - this.registry.set('crypStats', cryp); + this.registry.set('constructStats', construct); }; - // Cryp interaction box for adding items - const crypInteract = this.add + // Construct interaction box for adding items + const constructInteract = this.add .rectangle(ROW_X, ROW_Y, BOX_WIDTH, BOX_HEIGHT, FILL, ACTIVE_FILL) .setInteractive() .setOrigin(0) .on('pointerdown', selectFn); - crypInteract.itemSelect = () => { - crypInteract.setFillStyle(COLOURS.SELECT); + constructInteract.itemSelect = () => { + constructInteract.setFillStyle(COLOURS.SELECT); }; - crypInteract.itemDeselect = () => { - crypInteract.setFillStyle(FILL, ACTIVE_FILL); + constructInteract.itemDeselect = () => { + constructInteract.setFillStyle(FILL, ACTIVE_FILL); }; - crypInteract.cryp = cryp; + constructInteract.construct = construct; - // Cryp Avatar - const { name } = cryp; - const crypImage = this.add.image( - crypInteract.getCenter().x - crypInteract.width / 4, - crypInteract.getCenter().y, + // Construct Avatar + const { name } = construct; + const constructImage = this.add.image( + constructInteract.getCenter().x - constructInteract.width / 4, + constructInteract.getCenter().y, 'aztec', genAvatar(name) ); // Add text info - const yCrypTextAlgin = Math.floor(crypInteract.y + TEXT_MARGIN / 2); - const xCrypNameAlign = Math.floor(crypInteract.x + crypInteract.width * 1 / 10); - const crypInfoText = this.add.text(xCrypNameAlign, yCrypTextAlgin, name, TEXT.HEADER); + const yConstructTextAlgin = Math.floor(constructInteract.y + TEXT_MARGIN / 2); + const xConstructNameAlign = Math.floor(constructInteract.x + constructInteract.width * 1 / 10); + const constructInfoText = this.add.text(xConstructNameAlign, yConstructTextAlgin, name, TEXT.HEADER); const colourText = (c, j) => { // Placeholder for when gems are implemented - const gemText = this.add.text(crypInteract.x + crypInteract.width * (j + 3) / 6, yCrypTextAlgin, `${c[0]} - ${c[1]}`, TEXT.HEADER); - this.crypGroup.add(gemText); + const gemText = this.add.text(constructInteract.x + constructInteract.width * (j + 3) / 6, yConstructTextAlgin, `${c[0]} - ${c[1]}`, TEXT.HEADER); + this.constructGroup.add(gemText); }; - const { red, green, blue } = cryp.colours; - const CRYP_COLOURS = [ + const { red, green, blue } = construct.colours; + const CONSTRUCT_COLOURS = [ ['R', red], ['G', green], ['B', blue], ]; - CRYP_COLOURS.forEach(colourText); + CONSTRUCT_COLOURS.forEach(colourText); - this.crypGroup.addMultiple([crypInteract, crypImage, crypInfoText]); + this.constructGroup.addMultiple([constructInteract, constructImage, constructInfoText]); - const crypSkill = (stat, j) => { + const constructSkill = (stat, j) => { const SKILL_WIDTH = Math.floor(BOX_WIDTH / 2); const SKILL_HEIGHT = Math.floor(BOX_HEIGHT / 8); - const SKILL_X = crypInteract.getCenter().x + crypInteract.width / 4; - const SKILL_Y = crypInteract.y + SKILL_HEIGHT * 1.15 * (j + 1.6); + const SKILL_X = constructInteract.getCenter().x + constructInteract.width / 4; + const SKILL_Y = constructInteract.y + SKILL_HEIGHT * 1.15 * (j + 1.6); const itemObj = new Item(this, stat.skill, j, SKILL_X, SKILL_Y, SKILL_WIDTH, SKILL_HEIGHT); this.add.existing(itemObj); itemObj.setInteractive(); - const itemInfo = { item: stat.skill, cryp }; + const itemInfo = { item: stat.skill, construct }; itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo)); - this.crypGroup.add(itemObj); + this.constructGroup.add(itemObj); }; - cryp.skills.forEach(crypSkill); + construct.skills.forEach(constructSkill); - const crypSpec = (spec, j) => { + const constructSpec = (spec, j) => { const SKILL_WIDTH = Math.floor(BOX_WIDTH * 0.15); const SKILL_HEIGHT = Math.floor(BOX_HEIGHT * 0.2); - const SKILL_X = Math.floor(crypInteract.x + BOX_WIDTH * (0.6 + j) * 0.175); - const SKILL_Y = Math.floor(crypInteract.y + BOX_HEIGHT * 0.875); + const SKILL_X = Math.floor(constructInteract.x + BOX_WIDTH * (0.6 + j) * 0.175); + const SKILL_Y = Math.floor(constructInteract.y + BOX_HEIGHT * 0.875); const itemObj = new Item(this, spec, j, SKILL_X, SKILL_Y, SKILL_WIDTH, SKILL_HEIGHT); itemObj.setInteractive(); - const itemInfo = { item: spec, cryp }; + const itemInfo = { item: spec, construct }; itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo)); this.add.existing(itemObj); - this.crypGroup.add(itemObj); + this.constructGroup.add(itemObj); }; - cryp.specs.forEach(crypSpec); + construct.specs.forEach(constructSpec); }; - cryps.forEach(addCryp); + constructs.forEach(addConstruct); return true; } @@ -134,4 +134,4 @@ class MenuCrypList extends Phaser.Scene { } } -module.exports = MenuCrypList; +module.exports = MenuConstructList; diff --git a/phaser-client/src/scenes/menu.js b/phaser-client/src/scenes/menu.js index 78e6d749..091335d7 100644 --- a/phaser-client/src/scenes/menu.js +++ b/phaser-client/src/scenes/menu.js @@ -1,7 +1,7 @@ const Phaser = require('phaser'); // Scenes constantly showing -const MenuCrypList = require('./menu.cryps.list'); +const MenuConstructList = require('./menu.constructs.list'); const MenuNavigation = require('./menu.navigation'); const ItemList = require('./item.list'); // Scenes which change depending on menu context @@ -11,7 +11,7 @@ const StatSheet = require('./statsheet'); const ItemInfo = require('./item.info'); const FIXED_MENU_SCENES = [ - 'MenuCrypList', + 'MenuConstructList', 'MenuNavigation', 'ItemList', ]; @@ -37,7 +37,7 @@ class Menu extends Phaser.Scene { this.registry.get('ws').sendPlayerState(player.instance); // When we load the menu request the latest items // Item list will restart when the data comes in - this.scene.manager.add('MenuCrypList', MenuCrypList, true); + this.scene.manager.add('MenuConstructList', MenuConstructList, true); this.scene.manager.add('MenuNavigation', MenuNavigation, true); this.scene.manager.add('ItemList', ItemList, true); this.registry.set('inMenu', true); @@ -53,7 +53,7 @@ class Menu extends Phaser.Scene { case 'home': return this.cleanUp(); case 'zone': return this.newMainScene('Zones', Zones, data); case 'gameList': return this.newMainScene('GameList', GameList, data); - case 'crypStats': return this.newMainScene('StatSheet', StatSheet, data); + case 'constructStats': return this.newMainScene('StatSheet', StatSheet, data); case 'itemInfo': return this.newMainScene('ItemInfo', ItemInfo, data); default: return false; } diff --git a/phaser-client/src/scenes/statsheet.js b/phaser-client/src/scenes/statsheet.js index e7116f56..802a21d3 100644 --- a/phaser-client/src/scenes/statsheet.js +++ b/phaser-client/src/scenes/statsheet.js @@ -21,8 +21,8 @@ class DeleteHitBox extends Phaser.GameObjects.Rectangle { } const itemCheckHitbox = (scene, pointer) => { - const { list } = scene.scene.get('MenuCrypList').children; - const hitboxes = list.filter(c => c.cryp) + const { list } = scene.scene.get('MenuConstructList').children; + const hitboxes = list.filter(c => c.construct) .concat(scene.children.list.filter(c => c instanceof DeleteHitBox)); let found; @@ -47,12 +47,12 @@ class StatSheet extends Phaser.Scene { if (key === 'player') { console.log('grep'); console.log(data); - const cryp = data.cryps.find(c => c.id === this.cryp.id); - this.scene.restart(cryp); + const construct = data.constructs.find(c => c.id === this.construct.id); + this.scene.restart(construct); } } - create(cryp) { + create(construct) { this.registry.events.on('changedata', this.updateData, this); // const ws = this.registry.get('ws'); @@ -60,7 +60,7 @@ class StatSheet extends Phaser.Scene { if (!player) return false; // const { vbox } = player; - this.cryp = cryp; + this.construct = construct; /* const del = this.add.existing(new DeleteHitBox(this, X + WIDTH * 0.7, Y + HEIGHT * 0.6)); @@ -68,25 +68,25 @@ class StatSheet extends Phaser.Scene { .setOrigin(0.5, 0.5); */ - this.add.text(X, Y, cryp.name, TEXT.HEADER); + this.add.text(X, Y, construct.name, TEXT.HEADER); - const crypStat = (stat, i) => { + const constructStat = (stat, i) => { const STAT_X = X; const STAT_Y = Y + (i + 2) * TEXT_MARGIN; this.add.text(STAT_X, STAT_Y, `${stat.stat}: ${stat.base} -> ${stat.value}`, TEXT.NORMAL); }; - const CRYP_STATS = [ - cryp.hp, - cryp.red_shield, - cryp.blue_shield, - cryp.evasion, - cryp.red_damage, - cryp.blue_damage, - cryp.speed, + const CONSTRUCT_STATS = [ + construct.hp, + construct.red_shield, + construct.blue_shield, + construct.evasion, + construct.red_damage, + construct.blue_damage, + construct.speed, ]; - CRYP_STATS.forEach(crypStat); + CONSTRUCT_STATS.forEach(constructStat); /* const knownSkill = (skill, i) => { const SKILL_X = X + WIDTH * 0.4 + WIDTH * 0.125 * i; @@ -96,7 +96,7 @@ class StatSheet extends Phaser.Scene { this.input.setDraggable(itemObj); this.add.existing(itemObj); }; - cryp.skills.forEach(knownSkill); + construct.skills.forEach(knownSkill); this.add.text(X + WIDTH * 0.35, Y, 'Skills', TEXT.HEADER); this.add.text(X + WIDTH * 0.35, Y + HEIGHT * 0.25, 'Specs', TEXT.HEADER); @@ -108,7 +108,7 @@ class StatSheet extends Phaser.Scene { this.input.setDraggable(itemObj); this.add.existing(itemObj); }; - cryp.specs.forEach(knownSpec); + construct.specs.forEach(knownSpec); this.input.on('drag', (pointer, item, dragX, dragY) => { @@ -126,7 +126,7 @@ class StatSheet extends Phaser.Scene { if (hitBox) { hitBox.itemDeselect(); // add socket function for unlearn here - ws.sendVboxUnequip(vbox.instance, cryp.id, item.item); + ws.sendVboxUnequip(vbox.instance, construct.id, item.item); } return true; }); diff --git a/phaser-client/src/scenes/zones.js b/phaser-client/src/scenes/zones.js index 13596dfc..fcedab65 100644 --- a/phaser-client/src/scenes/zones.js +++ b/phaser-client/src/scenes/zones.js @@ -70,7 +70,7 @@ class Zones extends Phaser.Scene { // Check cursor hasn't significantly moved during point allocation // If panning and mouse release is on node it won't allocate if (gameObjects[0] instanceof Node) { - const team = this.registry.get('cryps').filter(c => c.active).map(c => c.id); + const team = this.registry.get('constructs').filter(c => c.active).map(c => c.id); if (gameObjects[0].success) return false; this.registry.get('ws').sendZoneJoin(zoneId, gameObjects[0].id, team); } diff --git a/phaser-client/src/socket.js b/phaser-client/src/socket.js index df705042..26c58848 100644 --- a/phaser-client/src/socket.js +++ b/phaser-client/src/socket.js @@ -2,7 +2,7 @@ const toast = require('izitoast'); const cbor = require('borc'); -const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://cryps.gg/ws' : 'ws://localhost:40000'; +const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://constructs.gg/ws' : 'ws://localhost:40000'; function errorToast(err) { console.error(err); @@ -41,8 +41,8 @@ function createSocket(events) { send({ method: 'account_demo', params: {} }); } - function sendAccountCryps() { - send({ method: 'account_cryps', params: {} }); + function sendAccountConstructs() { + send({ method: 'account_constructs', params: {} }); } function sendAccountInstances() { @@ -53,40 +53,40 @@ function createSocket(events) { send({ method: 'account_zone', params: {} }); } - function sendCrypSpawn(name) { - send({ method: 'cryp_spawn', params: { name } }); + function sendConstructSpawn(name) { + send({ method: 'construct_spawn', params: { name } }); } - function sendCrypLearn(id, skill) { - send({ method: 'cryp_learn', params: { id, skill } }); + function sendConstructLearn(id, skill) { + send({ method: 'construct_learn', params: { id, skill } }); } - function sendCrypForget(id, skill) { - send({ method: 'cryp_forget', params: { id, skill } }); + function sendConstructForget(id, skill) { + send({ method: 'construct_forget', params: { id, skill } }); } function sendGameState(id) { send({ method: 'game_state', params: { id } }); } - function sendGamePve(crypIds, mode) { - send({ method: 'game_pve', params: { cryp_ids: crypIds, mode } }); + function sendGamePve(constructIds, mode) { + send({ method: 'game_pve', params: { construct_ids: constructIds, mode } }); } - function sendGamePvp(crypIds) { - send({ method: 'game_pvp', params: { cryp_ids: crypIds } }); + function sendGamePvp(constructIds) { + send({ method: 'game_pvp', params: { construct_ids: constructIds } }); } - function sendGameJoin(gameId, crypIds) { - send({ method: 'game_join', params: { game_id: gameId, cryp_ids: crypIds } }); + function sendGameJoin(gameId, constructIds) { + send({ method: 'game_join', params: { game_id: gameId, construct_ids: constructIds } }); } function sendSpecForget(id, spec) { - send({ method: 'cryp_unspec', params: { id, spec } }); + send({ method: 'construct_unspec', params: { id, spec } }); } - function sendPlayerCrypsSet(instanceId, crypIds) { - send({ method: 'player_cryps_set', params: { instance_id: instanceId, cryp_ids: crypIds } }); + function sendPlayerConstructsSet(instanceId, constructIds) { + send({ method: 'player_constructs_set', params: { instance_id: instanceId, construct_ids: constructIds } }); } function sendPlayerState(instanceId) { @@ -97,12 +97,12 @@ function createSocket(events) { send({ method: 'player_vbox_accept', params: { instance_id: instanceId, group, index } }); } - function sendVboxApply(instanceId, crypId, index) { - send({ method: 'player_vbox_apply', params: { instance_id: instanceId, cryp_id: crypId, index } }); + function sendVboxApply(instanceId, constructId, index) { + send({ method: 'player_vbox_apply', params: { instance_id: instanceId, construct_id: constructId, index } }); } - function sendVboxUnequip(instanceId, crypId, target) { - send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, cryp_id: crypId, target } }); + function sendVboxUnequip(instanceId, constructId, target) { + send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, construct_id: constructId, target } }); } function sendVboxDiscard(instanceId) { @@ -117,18 +117,18 @@ function createSocket(events) { send({ method: 'player_vbox_reclaim', params: { instance_id: instanceId, index } }); } - function sendGameSkill(gameId, crypId, targetCrypId, skill) { + function sendGameSkill(gameId, constructId, targetConstructId, skill) { send({ method: 'game_skill', params: { - game_id: gameId, cryp_id: crypId, target_cryp_id: targetCrypId, skill, + game_id: gameId, construct_id: constructId, target_construct_id: targetConstructId, skill, }, }); events.setActiveSkill(null); } - function sendGameTarget(gameId, crypId, skillId) { - send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, skill_id: skillId } }); + function sendGameTarget(gameId, constructId, skillId) { + send({ method: 'game_target', params: { game_id: gameId, construct_id: constructId, skill_id: skillId } }); events.setActiveSkill(null); } @@ -136,16 +136,16 @@ function createSocket(events) { send({ method: 'zone_create', params: {} }); } - function sendZoneJoin(zoneId, nodeId, crypIds) { - send({ method: 'zone_join', params: { zone_id: zoneId, node_id: nodeId, cryp_ids: crypIds } }); + function sendZoneJoin(zoneId, nodeId, constructIds) { + send({ method: 'zone_join', params: { zone_id: zoneId, node_id: nodeId, construct_ids: constructIds } }); } function sendZoneClose(zoneId) { send({ method: 'zone_close', params: { zone_id: zoneId } }); } - function sendInstanceJoin(cryps) { - send({ method: 'instance_join', params: { cryp_ids: cryps, pve: true } }); + function sendInstanceJoin(constructs) { + send({ method: 'instance_join', params: { construct_ids: constructs, pve: true } }); } function sendInstanceReady(instanceId) { @@ -165,7 +165,7 @@ function createSocket(events) { account = login; events.setAccount(login); - sendAccountCryps(); + sendAccountConstructs(); } function accountInstanceList(res) { @@ -173,9 +173,9 @@ function createSocket(events) { events.setInstanceList(instanceList); } - function accountCryps(response) { - const [structName, cryps] = response; - events.setCrypList(cryps); + function accountConstructs(response) { + const [structName, constructs] = response; + events.setConstructList(constructs); } function gameState(response) { @@ -183,8 +183,8 @@ function createSocket(events) { events.setGame(game); } - function crypSpawn(response) { - const [structName, cryp] = response; + function constructSpawn(response) { + const [structName, construct] = response; } function gamePve(response) { @@ -213,14 +213,14 @@ function createSocket(events) { // when the server sends a reply it will have one of these message types // this object wraps the reply types to a function const handlers = { - cryp_spawn: crypSpawn, - cryp_forget: () => true, - cryp_learn: () => true, + construct_spawn: constructSpawn, + construct_forget: () => true, + construct_learn: () => true, game_pve: gamePve, game_state: gameState, account_login: accountLogin, account_create: accountLogin, - account_cryps: accountCryps, + account_constructs: accountConstructs, account_instances: accountInstanceList, instance_scores: instanceScores, zone_create: res => console.log(res), @@ -232,9 +232,9 @@ function createSocket(events) { function errHandler(error) { switch (error) { case 'no active zone': return sendZoneCreate(); - case 'no cryps selected': return events.errorPrompt('select_cryps'); + case 'no constructs selected': return events.errorPrompt('select_constructs'); case 'node requirements not met': return events.errorPrompt('complete_nodes'); - case 'cryp at max skills (4)': return events.errorPrompt('max_skills'); + case 'construct at max skills (4)': return events.errorPrompt('max_skills'); default: return errorToast(error); @@ -301,7 +301,7 @@ function createSocket(events) { sendAccountLogin, sendAccountCreate, sendAccountDemo, - sendAccountCryps, + sendAccountConstructs, sendAccountInstances, sendAccountZone, sendGameState, @@ -310,9 +310,9 @@ function createSocket(events) { sendGameJoin, sendGameSkill, sendGameTarget, - sendCrypSpawn, - sendCrypLearn, - sendCrypForget, + sendConstructSpawn, + sendConstructLearn, + sendConstructForget, sendSpecForget, sendZoneCreate, sendZoneJoin, @@ -320,7 +320,7 @@ function createSocket(events) { sendInstanceJoin, sendInstanceReady, sendInstanceScores, - sendPlayerCrypsSet, + sendPlayerConstructsSet, sendPlayerState, sendVboxAccept, sendVboxApply, diff --git a/phaser-client/src/tutorial.js b/phaser-client/src/tutorial.js index a73ff00d..186927c7 100644 --- a/phaser-client/src/tutorial.js +++ b/phaser-client/src/tutorial.js @@ -9,34 +9,34 @@ function noMore(instance, thisToast) { } const WELCOME_MESSAGE = ` -Welcome to cryps.gg +Welcome to constructs.gg Enter a username and password and press register to sign up, or just press DEMO to quick start. `; const HOMEPAGE_MESSAGE = ` -This homepage shows your cryps, joinable online games, PVE options and your items.\n -If you have no cryps yet, press SPAWN and give your cryp a name to create one. -Once you have made a cryp, click on them to visit their stat page and teach them some SKILLS. +This homepage shows your constructs, joinable online games, PVE options and your items.\n +If you have no constructs yet, press SPAWN and give your construct a name to create one. +Once you have made a construct, click on them to visit their stat page and teach them some SKILLS. The stat page also has descriptions of each skill and their effects. -cryps have 3 basic stats: hp, red damage and magic damage. -Toggle whether a cryp is selected for your team by clicking the coloured stripes next to the cryp or press 1,2,3. +constructs have 3 basic stats: hp, red damage and magic damage. +Toggle whether a construct is selected for your team by clicking the coloured stripes next to the construct or press 1,2,3. Once you have a team ready press the New PVE Game button to start playing. `; const SKILL_PHASE_MESSAGE = ` -A cryps battle has two main phases. This first phase is called the SKILL PHASE. -Your cryps are positioned on the left, your opponent's are on the right. -In the centre are your cryps' SKILLS, grayed out SKILLS are currently ON COOLDOWN. -A skill's cooldown reduces on every turn that cryp does not use a skill with a cooldown. -For the moment, drag ATTACK onto the opponent team to have your cryps attack them with red damage. +A constructs battle has two main phases. This first phase is called the SKILL PHASE. +Your constructs are positioned on the left, your opponent's are on the right. +In the centre are your constructs' SKILLS, grayed out SKILLS are currently ON COOLDOWN. +A skill's cooldown reduces on every turn that construct does not use a skill with a cooldown. +For the moment, drag ATTACK onto the opponent team to have your constructs attack them with red damage. `; // const TARGET_PHASE_MESSAGE = ` // This phase is the TARGET PHASE. -// In cryps you do not directly attack your opponent's cryps, you attack the opponent as a team -// and you and your opponent choose which cryp is the TARGET of each ability. -// Drag the incoming ATTACKS from the right hand side onto your own cryps. +// In constructs you do not directly attack your opponent's constructs, you attack the opponent as a team +// and you and your opponent choose which construct is the TARGET of each ability. +// Drag the incoming ATTACKS from the right hand side onto your own constructs. // It's wise to spread the damage around! // `; @@ -44,9 +44,9 @@ const RESOLUTION_PHASE_MESSAGE = ` The second phase is called the RESOLUTION PHASE. This phase happens automatically, every skill is RESOLVED in order of its SPEED. This is important because attacks only RESOLVE while their caster is still able to use the skill, -a fast skill that does a small amount of damage may KO an opponent cryp, causing any SKILLS +a fast skill that does a small amount of damage may KO an opponent construct, causing any SKILLS they have used to no longer RESOLVE! -Another example of this is the skill STUN. STUN causes an opponent cryp to be unable to use any +Another example of this is the skill STUN. STUN causes an opponent construct to be unable to use any abilities for TWO TURNS including the turn it resolves on. In other words it lasts for the rest of the turn it resolves on and the whole next turn. Try it now! @@ -54,10 +54,10 @@ Try it now! const FINISH_PHASE_MESSAGE = ` gg! The game has now concluded, if you were the winner you have been awarded with a STAT REROLL ITEM. -You can use this to reroll a stat on a cryp which may be lacking. +You can use this to reroll a stat on a construct which may be lacking. A good metric is that if a stat is more than 1/2 of its STAMINA that's a good roll. Now that you have learned the basics, press BACKSPACE to return to the main menu -and experiment with some combinations of SKILLS or replace the ones your cryps know in the STAT PAGE. +and experiment with some combinations of SKILLS or replace the ones your constructs know in the STAT PAGE. glhf! `; diff --git a/server/.env b/server/.env index f42f5c28..8866a855 100644 --- a/server/.env +++ b/server/.env @@ -1 +1 @@ -DATABASE_URL=postgres://cryps:craftbeer@localhost/cryps +DATABASE_URL=postgres://constructs:craftbeer@localhost/constructs diff --git a/server/Cargo.toml b/server/Cargo.toml index a0ed55f2..4732d280 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cryps" +name = "constructs" version = "0.1.0" authors = ["ntr "] @@ -13,7 +13,7 @@ serde_cbor = "0.9" chrono = { version = "0.4", features = ["serde"] } tungstenite = "0.6" -bcrypt = "0.2" +bconstructt = "0.2" dotenv = "0.9.0" postgres = { version = "0.15", features = ["with-uuid"] } diff --git a/server/src/account.rs b/server/src/account.rs index d2cadc7f..31ca4d8f 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -1,5 +1,5 @@ use uuid::Uuid; -use bcrypt::{hash, verify}; +use bconstructt::{hash, verify}; use rand::{thread_rng, Rng}; use rand::distributions::Alphanumeric; use std::iter; @@ -9,7 +9,7 @@ use postgres::transaction::Transaction; use rpc::{AccountCreateParams, AccountLoginParams}; -use cryp::{Cryp, cryp_recover}; +use construct::{Construct, construct_recover}; use instance::{Instance, instance_delete}; use failure::Error; @@ -155,34 +155,34 @@ pub fn account_login(params: AccountLoginParams, tx: &mut Transaction) -> Result return Ok(account); } -pub fn account_cryps(tx: &mut Transaction, account: &Account) -> Result, Error> { +pub fn account_constructs(tx: &mut Transaction, account: &Account) -> Result, Error> { let query = " SELECT data - FROM cryps + FROM constructs WHERE account = $1; "; let result = tx .query(query, &[&account.id])?; - let cryps: Result, _> = result.iter() + let constructs: Result, _> = result.iter() .map(|row| { - let cryp_bytes: Vec = row.get(0); - match from_slice::(&cryp_bytes) { + let construct_bytes: Vec = row.get(0); + match from_slice::(&construct_bytes) { Ok(c) => Ok(c), - Err(_e) => cryp_recover(cryp_bytes, tx), + Err(_e) => construct_recover(construct_bytes, tx), } }) .collect(); // catch any errors - if cryps.is_err() { - return Err(err_msg("could not deserialize a cryp")); + if constructs.is_err() { + return Err(err_msg("could not deserialize a construct")); } - let mut cryps = cryps.unwrap(); - cryps.sort_by_key(|c| c.id); - return Ok(cryps); + let mut constructs = constructs.unwrap(); + constructs.sort_by_key(|c| c.id); + return Ok(constructs); } pub fn account_instances(tx: &mut Transaction, account: &Account) -> Result, Error> { diff --git a/server/src/cryp.rs b/server/src/cryp.rs index b7efba0e..9c29721d 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -8,7 +8,7 @@ use failure::Error; use failure::err_msg; use account::{Account}; -use rpc::{CrypSpawnParams}; +use rpc::{ConstructSpawnParams}; use skill::{Skill, Cooldown, Effect, Cast, Colour, Immunity, Disable, Event}; use spec::{Spec}; use item::{Item}; @@ -25,15 +25,15 @@ impl Colours { Colours { red: 0, green: 0, blue: 0 } } - pub fn from_cryp(cryp: &Cryp) -> Colours { + pub fn from_construct(construct: &Construct) -> Colours { let mut count = Colours::new(); - for spec in cryp.specs.iter() { + for spec in construct.specs.iter() { let v = Item::from(*spec); v.colours(&mut count); } - for cs in cryp.skills.iter() { + for cs in construct.skills.iter() { let v = Item::from(cs.skill); v.colours(&mut count); } @@ -44,15 +44,15 @@ impl Colours { #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] -pub struct CrypSkill { +pub struct ConstructSkill { pub skill: Skill, pub self_targeting: bool, pub cd: Cooldown, } -impl CrypSkill { - pub fn new(skill: Skill) -> CrypSkill { - CrypSkill { +impl ConstructSkill { + pub fn new(skill: Skill) -> ConstructSkill { + ConstructSkill { skill, self_targeting: skill.self_targeting(), cd: skill.base_cd(), @@ -69,24 +69,24 @@ pub enum EffectMeta { } #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] -pub struct CrypEffect { +pub struct ConstructEffect { pub effect: Effect, pub duration: u8, pub meta: Option, pub tick: Option, } -impl CrypEffect { - pub fn new(effect: Effect, duration: u8) -> CrypEffect { - CrypEffect { effect, duration, meta: None, tick: None } +impl ConstructEffect { + pub fn new(effect: Effect, duration: u8) -> ConstructEffect { + ConstructEffect { effect, duration, meta: None, tick: None } } - pub fn set_tick(mut self, tick: Cast) -> CrypEffect { + pub fn set_tick(mut self, tick: Cast) -> ConstructEffect { self.tick = Some(tick); self } - pub fn set_meta(mut self, meta: EffectMeta) -> CrypEffect { + pub fn set_meta(mut self, meta: EffectMeta) -> ConstructEffect { self.meta = Some(meta); self } @@ -119,20 +119,20 @@ pub enum Stat { } #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] -pub struct CrypStat { +pub struct ConstructStat { base: u64, value: u64, max: u64, pub stat: Stat, } -impl CrypStat { - // pub fn set(&mut self, v: u64, specs: &Vec) -> &mut CrypStat { +impl ConstructStat { + // pub fn set(&mut self, v: u64, specs: &Vec) -> &mut ConstructStat { // self.base = v; // self.recalculate(specs) // } - pub fn recalculate(&mut self, specs: &Vec, cryp_colours: &Colours, player_colours: &Colours) -> &mut CrypStat { + pub fn recalculate(&mut self, specs: &Vec, construct_colours: &Colours, player_colours: &Colours) -> &mut ConstructStat { let specs = specs .iter() .filter(|s| s.affects().contains(&self.stat)) @@ -141,19 +141,19 @@ impl CrypStat { // applied with fold because it can be zeroed or multiplied // but still needs access to the base amount - let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base, cryp_colours, player_colours)); + let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base, construct_colours, player_colours)); self.value = value; self.max = value; self } - pub fn reduce(&mut self, amt: u64) -> &mut CrypStat { + pub fn reduce(&mut self, amt: u64) -> &mut ConstructStat { self.value = self.value.saturating_sub(amt); self } - pub fn increase(&mut self, amt: u64) -> &mut CrypStat { + pub fn increase(&mut self, amt: u64) -> &mut ConstructStat { self.value = *[ self.value.saturating_add(amt), self.max @@ -162,7 +162,7 @@ impl CrypStat { self } - pub fn force(&mut self, v: u64) -> &mut CrypStat { + pub fn force(&mut self, v: u64) -> &mut ConstructStat { self.base = v; self.value = v; self.max = v; @@ -172,45 +172,45 @@ impl CrypStat { } #[derive(Debug,Clone,Serialize,Deserialize)] -pub struct CrypRecover { +pub struct ConstructRecover { pub id: Uuid, pub account: Uuid, pub name: String, } #[derive(Debug,Clone,Serialize,Deserialize)] -pub struct Cryp { +pub struct Construct { pub id: Uuid, pub account: Uuid, - pub red_damage: CrypStat, - pub red_life: CrypStat, - pub blue_life: CrypStat, - pub blue_damage: CrypStat, - pub green_damage: CrypStat, - pub speed: CrypStat, - pub green_life: CrypStat, - pub evasion: CrypStat, - pub skills: Vec, - pub effects: Vec, + pub red_damage: ConstructStat, + pub red_life: ConstructStat, + pub blue_life: ConstructStat, + pub blue_damage: ConstructStat, + pub green_damage: ConstructStat, + pub speed: ConstructStat, + pub green_life: ConstructStat, + pub evasion: ConstructStat, + pub skills: Vec, + pub effects: Vec, pub specs: Vec, pub colours: Colours, pub name: String, } -impl Cryp { - pub fn new() -> Cryp { +impl Construct { + pub fn new() -> Construct { let id = Uuid::new_v4(); - return Cryp { + return Construct { id, account: id, - red_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::RedDamage }, - red_life: CrypStat { base: 0, value: 0, max: 0, stat: Stat::RedLife }, - blue_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::BlueDamage }, - blue_life: CrypStat { base: 0, value: 0, max: 0, stat: Stat::BlueLife }, - green_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::GreenDamage }, - green_life: CrypStat { base: 1024, value: 1024, max: 1024, stat: Stat::GreenLife }, - speed: CrypStat { base: 128, value: 128, max: 128, stat: Stat::Speed }, - evasion: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Evasion }, + red_damage: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::RedDamage }, + red_life: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::RedLife }, + blue_damage: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::BlueDamage }, + blue_life: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::BlueLife }, + green_damage: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::GreenDamage }, + green_life: ConstructStat { base: 1024, value: 1024, max: 1024, stat: Stat::GreenLife }, + speed: ConstructStat { base: 128, value: 128, max: 128, stat: Stat::Speed }, + evasion: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::Evasion }, skills: vec![], effects: vec![], specs: vec![], @@ -219,28 +219,28 @@ impl Cryp { }; } - pub fn named(mut self, name: &String) -> Cryp { + pub fn named(mut self, name: &String) -> Construct { self.name = name.clone(); self } - pub fn set_account(mut self, account: Uuid) -> Cryp { + pub fn set_account(mut self, account: Uuid) -> Construct { self.account = account; self } - pub fn learn(mut self, s: Skill) -> Cryp { - self.skills.push(CrypSkill::new(s)); - self.colours = Colours::from_cryp(&self); + pub fn learn(mut self, s: Skill) -> Construct { + self.skills.push(ConstructSkill::new(s)); + self.colours = Colours::from_construct(&self); self } - pub fn learn_mut(&mut self, s: Skill) -> &mut Cryp { - self.skills.push(CrypSkill::new(s)); + pub fn learn_mut(&mut self, s: Skill) -> &mut Construct { + self.skills.push(ConstructSkill::new(s)); self.calculate_colours() } - pub fn forget(&mut self, skill: Skill) -> Result<&mut Cryp, Error> { + pub fn forget(&mut self, skill: Skill) -> Result<&mut Construct, Error> { match self.skills.iter().position(|s| s.skill == skill) { Some(i) => { self.skills.remove(i); @@ -250,7 +250,7 @@ impl Cryp { } } - pub fn spec_add(&mut self, spec: Spec) -> Result<&mut Cryp, Error> { + pub fn spec_add(&mut self, spec: Spec) -> Result<&mut Construct, Error> { if self.specs.len() >= 6 { return Err(err_msg("maximum specs equipped")); } @@ -259,7 +259,7 @@ impl Cryp { return Ok(self.calculate_colours()); } - pub fn spec_remove(&mut self, spec: Spec) -> Result<&mut Cryp, Error> { + pub fn spec_remove(&mut self, spec: Spec) -> Result<&mut Construct, Error> { match self.specs.iter().position(|s| *s == spec) { Some(p) => self.specs.remove(p), None => return Err(err_msg("spec not found")), @@ -268,12 +268,12 @@ impl Cryp { Ok(self.calculate_colours()) } - fn calculate_colours(&mut self) -> &mut Cryp { - self.colours = Colours::from_cryp(&self); + fn calculate_colours(&mut self) -> &mut Construct { + self.colours = Colours::from_construct(&self); self } - pub fn apply_modifiers(&mut self, player_colours: &Colours) -> &mut Cryp { + pub fn apply_modifiers(&mut self, player_colours: &Colours) -> &mut Construct { self.specs.sort_unstable(); self.red_damage.recalculate(&self.specs, &self.colours, player_colours); @@ -292,7 +292,7 @@ impl Cryp { self.green_life.value == 0 } - pub fn force_ko(&mut self) -> &mut Cryp { + pub fn force_ko(&mut self) -> &mut Construct { self.green_life.value = 0; self } @@ -340,7 +340,7 @@ impl Cryp { self.effects.iter().any(|s| s.effect == effect) } - pub fn available_skills(&self) -> Vec<&CrypSkill> { + pub fn available_skills(&self) -> Vec<&ConstructSkill> { self.skills.iter() .filter(|s| s.cd.is_none()) .filter(|s| self.disabled(s.skill).is_none()) @@ -377,19 +377,19 @@ impl Cryp { self.skills.iter().any(|s| s.skill == skill) } - pub fn skill_on_cd(&self, skill: Skill) -> Option<&CrypSkill> { + pub fn skill_on_cd(&self, skill: Skill) -> Option<&ConstructSkill> { self.skills.iter().find(|s| s.skill == skill && s.cd.is_some()) } - pub fn skill_set_cd(&mut self, skill: Skill) -> &mut Cryp { + pub fn skill_set_cd(&mut self, skill: Skill) -> &mut Construct { let i = self.skills.iter().position(|s| s.skill == skill).unwrap(); self.skills.remove(i); - self.skills.push(CrypSkill::new(skill)); + self.skills.push(ConstructSkill::new(skill)); self } - pub fn reduce_cooldowns(&mut self) -> &mut Cryp { + pub fn reduce_cooldowns(&mut self) -> &mut Construct { for skill in self.skills.iter_mut() { // if used cooldown if skill.skill.base_cd().is_some() { @@ -412,7 +412,7 @@ impl Cryp { self } - pub fn reduce_effect_durations(&mut self) -> &mut Cryp { + pub fn reduce_effect_durations(&mut self) -> &mut Construct { self.effects = self.effects.clone().into_iter().filter_map(|mut effect| { effect.duration = effect.duration.saturating_sub(1); @@ -422,7 +422,7 @@ impl Cryp { // info!("reduced effect {:?}", effect); return Some(effect); - }).collect::>(); + }).collect::>(); self } @@ -734,7 +734,7 @@ impl Cryp { return events; } - pub fn add_effect(&mut self, skill: Skill, effect: CrypEffect) -> Event { + pub fn add_effect(&mut self, skill: Skill, effect: ConstructEffect) -> Event { if let Some(immunity) = self.immune(skill) { return Event::Immunity { skill, @@ -776,10 +776,10 @@ impl Cryp { } } -pub fn cryp_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result { +pub fn construct_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result { let query = " SELECT data - FROM cryps + FROM constructs WHERE id = $1 AND account = $2; "; @@ -787,110 +787,110 @@ pub fn cryp_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result = result.get(0); - let cryp = from_slice::(&cryp_bytes).or_else(|_| cryp_recover(cryp_bytes, tx))?; + let result = result.iter().next().ok_or(format_err!("construct {:} not found", id))?; + let construct_bytes: Vec = result.get(0); + let construct = from_slice::(&construct_bytes).or_else(|_| construct_recover(construct_bytes, tx))?; - return Ok(cryp); + return Ok(construct); } -pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Account) -> Result { - let cryp = Cryp::new() +pub fn construct_spawn(params: ConstructSpawnParams, tx: &mut Transaction, account: &Account) -> Result { + let construct = Construct::new() .named(¶ms.name) .set_account(account.id); - let cryp_bytes = to_vec(&cryp)?; + let construct_bytes = to_vec(&construct)?; let query = " - INSERT INTO cryps (id, account, data) + INSERT INTO constructs (id, account, data) VALUES ($1, $2, $3) RETURNING id, account; "; let result = tx - .query(query, &[&cryp.id, &account.id, &cryp_bytes])?; + .query(query, &[&construct.id, &account.id, &construct_bytes])?; let _returned = result.iter().next().ok_or(err_msg("no row returned"))?; - // info!("{:?} spawned cryp {:}", account.id, cryp.id); + // info!("{:?} spawned construct {:}", account.id, construct.id); - return Ok(cryp); + return Ok(construct); } -pub fn cryp_write(cryp: Cryp, tx: &mut Transaction) -> Result { - let cryp_bytes = to_vec(&cryp)?; +pub fn construct_write(construct: Construct, tx: &mut Transaction) -> Result { + let construct_bytes = to_vec(&construct)?; let query = " - UPDATE cryps + UPDATE constructs SET data = $1, updated_at = now() WHERE id = $2 RETURNING id, account, data; "; let result = tx - .query(query, &[&cryp_bytes, &cryp.id])?; + .query(query, &[&construct_bytes, &construct.id])?; let _returned = result.iter().next().expect("no row returned"); - // info!("{:?} wrote cryp", cryp.id); + // info!("{:?} wrote construct", construct.id); - return Ok(cryp); + return Ok(construct); } -pub fn cryp_recover(cryp_bytes: Vec, tx: &mut Transaction) -> Result { - let c = from_slice::(&cryp_bytes)?; +pub fn construct_recover(construct_bytes: Vec, tx: &mut Transaction) -> Result { + let c = from_slice::(&construct_bytes)?; - let mut cryp = Cryp::new() + let mut construct = Construct::new() .named(&c.name) .set_account(c.account); - cryp.id = c.id; + construct.id = c.id; - info!("recovered cryp {:?}", c.name); + info!("recovered construct {:?}", c.name); - return cryp_write(cryp, tx); + return construct_write(construct, tx); } #[cfg(test)] mod tests { - use cryp::*; + use construct::*; use util::IntPct; #[test] - fn create_cryp_test() { - let cryp = Cryp::new() + fn create_construct_test() { + let construct = Construct::new() .named(&"hatchling".to_string()); - assert_eq!(cryp.name, "hatchling".to_string()); + assert_eq!(construct.name, "hatchling".to_string()); return; } #[test] - fn cryp_colours_test() { - let mut cryp = Cryp::new() + fn construct_colours_test() { + let mut construct = Construct::new() .named(&"redboi".to_string()); - cryp.learn_mut(Skill::Strike); - cryp.spec_add(Spec::GreenLifeI).unwrap(); - cryp.spec_add(Spec::RedDamageI).unwrap(); - cryp.spec_add(Spec::RedDamageI).unwrap(); - cryp.spec_add(Spec::BlueLifeI).unwrap(); + construct.learn_mut(Skill::Strike); + construct.spec_add(Spec::GreenLifeI).unwrap(); + construct.spec_add(Spec::RedDamageI).unwrap(); + construct.spec_add(Spec::RedDamageI).unwrap(); + construct.spec_add(Spec::BlueLifeI).unwrap(); - assert_eq!(cryp.colours.red, 6); - assert_eq!(cryp.colours.green, 2); - assert_eq!(cryp.colours.blue, 2); + assert_eq!(construct.colours.red, 6); + assert_eq!(construct.colours.green, 2); + assert_eq!(construct.colours.blue, 2); return; } #[test] - fn cryp_player_modifiers_test() { - let mut cryp = Cryp::new() + fn construct_player_modifiers_test() { + let mut construct = Construct::new() .named(&"player player".to_string()); - cryp.spec_add(Spec::RedDamageI).unwrap(); - cryp.spec_add(Spec::GreenDamageI).unwrap(); - cryp.spec_add(Spec::BlueDamageI).unwrap(); + construct.spec_add(Spec::RedDamageI).unwrap(); + construct.spec_add(Spec::GreenDamageI).unwrap(); + construct.spec_add(Spec::BlueDamageI).unwrap(); let player_colours = Colours { red: 5, @@ -898,11 +898,11 @@ mod tests { blue: 25, }; - cryp.apply_modifiers(&player_colours); + construct.apply_modifiers(&player_colours); - assert!(cryp.red_damage.value == cryp.red_damage.base + cryp.red_damage.base.pct(20)); - assert!(cryp.green_damage.value == cryp.green_damage.base + cryp.green_damage.base.pct(40)); - assert!(cryp.blue_damage.value == cryp.blue_damage.base + cryp.blue_damage.base.pct(80)); + assert!(construct.red_damage.value == construct.red_damage.base + construct.red_damage.base.pct(20)); + assert!(construct.green_damage.value == construct.green_damage.base + construct.green_damage.base.pct(40)); + assert!(construct.blue_damage.value == construct.blue_damage.base + construct.blue_damage.base.pct(80)); return; } diff --git a/server/src/game.rs b/server/src/game.rs index 5eaefbc5..c4509030 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -13,7 +13,7 @@ use failure::err_msg; use account::Account; use rpc::{GameStateParams, GameSkillParams}; -use cryp::{Cryp}; +use construct::{Construct}; use skill::{Skill, Effect, Cast, Resolution, Event, resolution_steps}; use player::{Player}; use instance::{instance_game_finished, global_game_finished}; @@ -29,7 +29,7 @@ pub enum Phase { #[derive(Debug,Clone,Serialize,Deserialize)] pub struct Game { pub id: Uuid, - pub player_cryps: usize, + pub player_constructs: usize, pub player_num: usize, pub players: Vec, pub phase: Phase, @@ -44,7 +44,7 @@ impl Game { pub fn new() -> Game { return Game { id: Uuid::new_v4(), - player_cryps: 0, + player_constructs: 0, player_num: 0, players: vec![], phase: Phase::Start, @@ -61,8 +61,8 @@ impl Game { self } - pub fn set_player_cryps(&mut self, size: usize) -> &mut Game { - self.player_cryps = size; + pub fn set_player_constructs(&mut self, size: usize) -> &mut Game { + self.player_constructs = size; self } @@ -84,12 +84,12 @@ impl Game { return Err(err_msg("player already in game")); } - if player.cryps.iter().all(|c| c.skills.len() == 0) { + if player.constructs.iter().all(|c| c.skills.len() == 0) { info!("WARNING: {:?} has no skills and has forfeited {:?}", player.name, self.id); player.forfeit(); } - let player_description = player.cryps.iter().map(|c| c.name.clone()).collect::>().join(", "); + let player_description = player.constructs.iter().map(|c| c.name.clone()).collect::>().join(", "); self.log.push(format!("{:} has joined the game. [{:}]", player.name, player_description)); self.players.push(player); @@ -105,42 +105,42 @@ impl Game { .ok_or(format_err!("{:?} not in game", id)) } - pub fn cryp_by_id(&mut self, id: Uuid) -> Option<&mut Cryp> { - match self.players.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == id)) { - Some(player) => player.cryps.iter_mut().find(|c| c.id == id), + pub fn construct_by_id(&mut self, id: Uuid) -> Option<&mut Construct> { + match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == id)) { + Some(player) => player.constructs.iter_mut().find(|c| c.id == id), None => None, } } - pub fn cryp_by_id_take(&mut self, id: Uuid) -> Cryp { - match self.players.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == id)) { + pub fn construct_by_id_take(&mut self, id: Uuid) -> Construct { + match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == id)) { Some(player) => { - let i = player.cryps.iter().position(|c| c.id == id).unwrap(); - player.cryps.remove(i) + let i = player.constructs.iter().position(|c| c.id == id).unwrap(); + player.constructs.remove(i) } None => panic!("id not in game {:}", id), } } - fn all_cryps(&self) -> Vec { + fn all_constructs(&self) -> Vec { self.players.clone() .into_iter() .flat_map( - |t| t.cryps + |t| t.constructs .into_iter()) - .collect::>() + .collect::>() } - pub fn update_cryp(&mut self, cryp: &mut Cryp) -> &mut Game { - match self.players.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == cryp.id)) { + pub fn update_construct(&mut self, construct: &mut Construct) -> &mut Game { + match self.players.iter_mut().find(|t| t.constructs.iter().any(|c| c.id == construct.id)) { Some(player) => { - let index = player.cryps.iter().position(|t| t.id == cryp.id).unwrap(); - player.cryps.remove(index); - player.cryps.push(cryp.clone()); - player.cryps.sort_unstable_by_key(|c| c.id); + let index = player.constructs.iter().position(|t| t.id == construct.id).unwrap(); + player.constructs.remove(index); + player.constructs.push(construct.clone()); + player.constructs.sort_unstable_by_key(|c| c.id); }, - None => panic!("cryp not in game"), + None => panic!("construct not in game"), }; self @@ -148,7 +148,7 @@ impl Game { pub fn can_start(&self) -> bool { return self.players.len() == self.player_num - && self.players.iter().all(|t| t.cryps.len() == self.player_cryps) + && self.players.iter().all(|t| t.constructs.len() == self.player_constructs) } pub fn start(mut self) -> Game { @@ -198,7 +198,7 @@ impl Game { .filter(|t| t.bot) { let player_player = self.players.iter().find(|t| t.id != mobs.id).unwrap(); - for mob in mobs.cryps.iter() { + for mob in mobs.constructs.iter() { let skill = mob.mob_select_skill(); // info!("{:?} {:?}", mob.name, skill); match skill { @@ -209,8 +209,8 @@ impl Game { // more than once let mut find_target = || { match s.defensive() { - true => &mobs.cryps[rng.gen_range(0, mobs.cryps.len())], - false => &player_player.cryps[rng.gen_range(0, player_player.cryps.len())], + true => &mobs.constructs[rng.gen_range(0, mobs.constructs.len())], + false => &player_player.constructs[rng.gen_range(0, player_player.constructs.len())], } }; @@ -231,7 +231,7 @@ impl Game { match self.add_skill(player_id, mob_id, target_id, s) { Ok(_) => (), Err(e) => { - info!("{:?}", self.cryp_by_id(mob_id)); + info!("{:?}", self.construct_by_id(mob_id)); panic!("{:?} unable to add pve mob skill {:?}", e, s); }, } @@ -242,7 +242,7 @@ impl Game { self } - fn add_skill(&mut self, player_id: Uuid, source_cryp_id: Uuid, target_cryp_id: Option, skill: Skill) -> Result<&mut Game, Error> { + fn add_skill(&mut self, player_id: Uuid, source_construct_id: Uuid, target_construct_id: Option, skill: Skill) -> Result<&mut Game, Error> { // check player in game self.player_by_id(player_id)?; @@ -251,8 +251,8 @@ impl Game { } let final_target_id = match skill.self_targeting() { - true => source_cryp_id, - false => match target_cryp_id { + true => source_construct_id, + false => match target_construct_id { Some(t) => t, None => return Err(err_msg("skill requires a target")), } @@ -260,49 +260,49 @@ impl Game { // target checks { - let target = match self.cryp_by_id(final_target_id) { + let target = match self.construct_by_id(final_target_id) { Some(c) => c, - None => return Err(err_msg("target cryp not in game")), + None => return Err(err_msg("target construct not in game")), }; // fixme for rez if target.is_ko() { - return Err(err_msg("target cryp is ko")); + return Err(err_msg("target construct is ko")); } } - // cryp checks + // construct checks { - let cryp = match self.cryp_by_id(source_cryp_id) { + let construct = match self.construct_by_id(source_construct_id) { Some(c) => c, - None => return Err(err_msg("cryp not in game")), + None => return Err(err_msg("construct not in game")), }; - if cryp.is_ko() { - return Err(err_msg("cryp is ko")); + if construct.is_ko() { + return Err(err_msg("construct is ko")); } - // check the cryp has the skill - if !cryp.knows(skill) { - return Err(err_msg("cryp does not have that skill")); + // check the construct has the skill + if !construct.knows(skill) { + return Err(err_msg("construct does not have that skill")); } - if cryp.skill_on_cd(skill).is_some() { + if construct.skill_on_cd(skill).is_some() { return Err(err_msg("abiltity on cooldown")); } // check here as well so uncastable spells don't go on the stack - if let Some(disable) = cryp.disabled(skill) { + if let Some(disable) = construct.disabled(skill) { return Err(format_err!("skill disabled {:?}", disable)); } } - // replace cryp skill - if let Some(s) = self.stack.iter_mut().position(|s| s.source_cryp_id == source_cryp_id) { + // replace construct skill + if let Some(s) = self.stack.iter_mut().position(|s| s.source_construct_id == source_construct_id) { self.stack.remove(s); } - let skill = Cast::new(source_cryp_id, player_id, final_target_id, skill); + let skill = Cast::new(source_construct_id, player_id, final_target_id, skill); self.stack.push(skill); return Ok(self); @@ -349,7 +349,7 @@ impl Game { let mut sorted = self.stack.clone(); sorted.iter_mut() .for_each(|s| { - let caster = self.cryp_by_id(s.source_cryp_id).unwrap(); + let caster = self.construct_by_id(s.source_construct_id).unwrap(); let speed = caster.skill_speed(s.skill); s.speed = speed; }); @@ -361,19 +361,19 @@ impl Game { self } - fn cryp_aoe_targets(&self, cryp_id: Uuid) -> Vec { + fn construct_aoe_targets(&self, construct_id: Uuid) -> Vec { self.players.iter() - .find(|t| t.cryps.iter().any(|c| c.id == cryp_id)) + .find(|t| t.constructs.iter().any(|c| c.id == construct_id)) .unwrap() - .cryps + .constructs .iter() .map(|c| c.id) .collect() } - pub fn get_targets(&self, skill: Skill, source: &Cryp, target_cryp_id: Uuid) -> Vec { + pub fn get_targets(&self, skill: Skill, source: &Construct, target_construct_id: Uuid) -> Vec { let target_player = self.players.iter() - .find(|t| t.cryps.iter().any(|c| c.id == target_cryp_id)) + .find(|t| t.constructs.iter().any(|c| c.id == target_construct_id)) .unwrap(); if let Some(t) = target_player.taunting() { @@ -381,8 +381,8 @@ impl Game { } match source.skill_is_aoe(skill) { - true => self.cryp_aoe_targets(target_cryp_id), - false => vec![target_cryp_id], + true => self.construct_aoe_targets(target_construct_id), + false => vec![target_construct_id], } } @@ -392,7 +392,7 @@ impl Game { } // find their statuses with ticks - let mut ticks = self.all_cryps() + let mut ticks = self.all_constructs() .iter() .flat_map( |c| c.effects @@ -442,30 +442,30 @@ impl Game { } fn progress_durations(&mut self, resolved: &Vec) -> &mut Game { - for mut cryp in self.all_cryps() { - // info!("progressing durations for {:}", cryp.name); + for mut construct in self.all_constructs() { + // info!("progressing durations for {:}", construct.name); - if cryp.is_ko() { + if construct.is_ko() { continue; } // only reduce cooldowns if no cd was used // have to borrow self for the skill check { - if let Some(skill) = resolved.iter().find(|s| s.source_cryp_id == cryp.id) { + if let Some(skill) = resolved.iter().find(|s| s.source_construct_id == construct.id) { if skill.used_cooldown() { - cryp.skill_set_cd(skill.skill); + construct.skill_set_cd(skill.skill); } else { - cryp.reduce_cooldowns(); + construct.reduce_cooldowns(); } } else { - cryp.reduce_cooldowns(); + construct.reduce_cooldowns(); } } // always reduce durations - cryp.reduce_effect_durations(); - self.update_cryp(&mut cryp); + construct.reduce_effect_durations(); + self.update_construct(&mut construct); } self @@ -536,11 +536,11 @@ impl Game { } pub fn finished(&self) -> bool { - self.players.iter().any(|t| t.cryps.iter().all(|c| c.is_ko())) + self.players.iter().any(|t| t.constructs.iter().all(|c| c.is_ko())) } pub fn winner(&self) -> Option<&Player> { - self.players.iter().find(|t| t.cryps.iter().any(|c| !c.is_ko())) + self.players.iter().find(|t| t.constructs.iter().any(|c| !c.is_ko())) } fn finish(mut self) -> Game { @@ -548,7 +548,7 @@ impl Game { self.log.push(format!("Game finished.")); { - let winner = self.players.iter().find(|t| t.cryps.iter().any(|c| !c.is_ko())); + let winner = self.players.iter().find(|t| t.constructs.iter().any(|c| !c.is_ko())); match winner { Some(w) => self.log.push(format!("Winner: {:}", w.name)), None => self.log.push(format!("Game was drawn.")), @@ -630,7 +630,7 @@ pub fn game_get(tx: &mut Transaction, id: Uuid) -> Result { None => return Err(err_msg("game not found")), }; - // tells from_slice to cast into a cryp + // tells from_slice to cast into a construct let game_bytes: Vec = returned.get("data"); let game = from_slice::(&game_bytes)?; @@ -700,7 +700,7 @@ pub fn game_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> { // game // .set_player_num(2) -// .set_player_cryps(3) +// .set_player_constructs(3) // .set_mode(GameMode::Pvp); // game_write(tx, &game)?; @@ -761,7 +761,7 @@ pub fn game_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> { // None => return Err(err_msg("game not found")), // }; -// // tells from_slice to cast into a cryp +// // tells from_slice to cast into a construct // let game_bytes: Vec = returned.get("data"); // let game = match from_slice::(&game_bytes) { // Ok(g) => g, @@ -805,7 +805,7 @@ pub fn game_update(tx: &mut Transaction, game: &Game) -> Result<(), Error> { pub fn game_skill(params: GameSkillParams, tx: &mut Transaction, account: &Account) -> Result { let mut game = game_get(tx, params.game_id)?; - game.add_skill(account.id, params.cryp_id, params.target_cryp_id, params.skill)?; + game.add_skill(account.id, params.construct_id, params.target_construct_id, params.skill)?; if game.skill_phase_finished() { game = game.resolve_phase_start(); @@ -830,17 +830,17 @@ pub fn game_ready(params: GameStateParams, tx: &mut Transaction, account: &Accou Ok(game) } -// pub fn game_pve_new(cryp_ids: Vec, mode: GameMode, tx: &mut Transaction, account: &Account) -> Result { -// if cryp_ids.len() == 0 { -// return Err(err_msg("no cryps selected")); +// pub fn game_pve_new(construct_ids: Vec, mode: GameMode, tx: &mut Transaction, account: &Account) -> Result { +// if construct_ids.len() == 0 { +// return Err(err_msg("no constructs selected")); // } -// let cryps = cryp_ids +// let constructs = construct_ids // .iter() -// .map(|id| cryp_get(tx, *id, account.id)) -// .collect::, Error>>()?; +// .map(|id| construct_get(tx, *id, account.id)) +// .collect::, Error>>()?; -// if cryps.len() > 3 { +// if constructs.len() > 3 { // return Err(err_msg("player size too large (3 max)")); // } @@ -850,16 +850,16 @@ pub fn game_ready(params: GameStateParams, tx: &mut Transaction, account: &Accou // game; // .set_player_num(2) -// .set_player_cryps(cryps.len()) +// .set_player_constructs(constructs.len()) // .set_mode(mode); // // create the mob player -// let mob_player = generate_mob_player(mode, &cryps); +// let mob_player = generate_mob_player(mode, &constructs); // // add the players // let mut plr_player = Player::new(account.id); // plr_player -// .set_cryps(cryps); +// .set_constructs(constructs); // game @@ -872,7 +872,7 @@ pub fn game_ready(params: GameStateParams, tx: &mut Transaction, account: &Accou // } // pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result { -// let game = game_pve_new(params.cryp_ids, GameMode::Normal, tx, account)?; +// let game = game_pve_new(params.construct_ids, GameMode::Normal, tx, account)?; // // persist // game_write(tx, &game)?; @@ -887,7 +887,7 @@ pub fn game_instance_new(tx: &mut Transaction, players: Vec, game_id: Uu game .set_player_num(2) - .set_player_cryps(3) + .set_player_constructs(3) .set_instance(instance_id); // create the initiators player @@ -924,11 +924,11 @@ pub fn game_instance_new(tx: &mut Transaction, players: Vec, game_id: Uu #[cfg(test)] mod tests { use game::*; - use cryp::*; + use construct::*; use util::IntPct; fn create_test_game() -> Game { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"pronounced \"creeep\"".to_string()) .learn(Skill::Attack) .learn(Skill::TestStun) @@ -940,7 +940,7 @@ mod tests { .learn(Skill::Stun) .learn(Skill::Block); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"lemongrass tea".to_string()) .learn(Skill::Attack) .learn(Skill::TestStun) @@ -956,7 +956,7 @@ mod tests { game .set_player_num(2) - .set_player_cryps(1); + .set_player_constructs(1); let x_player_id = Uuid::new_v4(); x.account = x_player_id; @@ -976,22 +976,22 @@ mod tests { } fn create_2v2_test_game() -> Game { - let mut i = Cryp::new() + let mut i = Construct::new() .named(&"pretaliate".to_string()) .learn(Skill::Attack) .learn(Skill::TestTouch); - let mut j = Cryp::new() + let mut j = Construct::new() .named(&"poy sian".to_string()) .learn(Skill::Attack) .learn(Skill::TestTouch); - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"pronounced \"creeep\"".to_string()) .learn(Skill::Attack) .learn(Skill::TestTouch); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"lemongrass tea".to_string()) .learn(Skill::Attack) .learn(Skill::TestTouch); @@ -1000,7 +1000,7 @@ mod tests { game .set_player_num(2) - .set_player_cryps(2); + .set_player_constructs(2); let i_player_id = Uuid::new_v4(); i.account = i_player_id; @@ -1028,11 +1028,11 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); - game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Attack).unwrap(); - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Attack).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1053,11 +1053,11 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); - game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::TestStun).unwrap(); - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestStun).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1068,7 +1068,7 @@ mod tests { // should auto progress back to skill phase assert!(game.phase == Phase::Skill); - // assert!(game.player_by_id(y_player.id).cryps[0].is_stunned()); + // assert!(game.player_by_id(y_player.id).constructs[0].is_stunned()); // assert!(game.player_by_id(y_player.id).skills_required() == 0); } @@ -1079,18 +1079,18 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); - game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().red_damage.force(1000000000); - game.player_by_id(y_player.id).unwrap().cryp_by_id(y_cryp.id).unwrap().speed.force(1000000000); + game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().red_damage.force(1000000000); + game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().speed.force(1000000000); // just in case // remove all mitigation - game.player_by_id(x_player.id).unwrap().cryp_by_id(x_cryp.id).unwrap().red_life.force(0); + game.player_by_id(x_player.id).unwrap().construct_by_id(x_construct.id).unwrap().red_life.force(0); - game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::TestStun).unwrap(); - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestStun).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1098,7 +1098,7 @@ mod tests { assert!(game.skill_phase_finished()); game = game.resolve_phase_start(); - assert!(!game.player_by_id(y_player.id).unwrap().cryps[0].is_stunned()); + assert!(!game.player_by_id(y_player.id).unwrap().constructs[0].is_stunned()); assert!(game.phase == Phase::Finish); } @@ -1109,18 +1109,18 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); // should auto progress back to skill phase assert!(game.phase == Phase::Skill); - assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Block).is_none()); - assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_some()); - assert!(game.player_by_id(x_player.id).unwrap().cryps[0].skill_on_cd(Skill::Block).is_none()); + assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none()); + assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_some()); + assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none()); - game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1129,20 +1129,20 @@ mod tests { // should auto progress back to skill phase assert!(game.phase == Phase::Skill); - assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_some()); + assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_some()); // second round // now we block and it should go back on cd - // game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Stun).unwrap(); - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); + // game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); - assert!(game.player_by_id(x_player.id).unwrap().cryps[0].skill_on_cd(Skill::Stun).is_none()); - assert!(game.player_by_id(y_player.id).unwrap().cryps[0].skill_on_cd(Skill::Block).is_none()); + assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_none()); + assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none()); } #[test] @@ -1152,11 +1152,11 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); - game.add_skill(x_player.id, x_cryp.id, None, Skill::TestParry).unwrap(); - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestStun).unwrap(); + game.add_skill(x_player.id, x_construct.id, None, Skill::TestParry).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestStun).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1164,9 +1164,9 @@ mod tests { game = game.resolve_phase_start(); // should not be stunned because of parry - assert!(game.player_by_id(x_player.id).unwrap().cryps[0].is_stunned() == false); + assert!(game.player_by_id(x_player.id).unwrap().constructs[0].is_stunned() == false); // riposte - assert_eq!(game.player_by_id(y_player.id).unwrap().cryps[0].green_life(), (1024 - x_cryp.red_damage().pct(Skill::Riposte.multiplier()))); + assert_eq!(game.player_by_id(y_player.id).unwrap().constructs[0].green_life(), (1024 - x_construct.red_damage().pct(Skill::Riposte.multiplier()))); } #[test] @@ -1176,29 +1176,29 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); - game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Corrupt); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Corrupt); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Corrupt).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Corrupt).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } // apply buff - game.add_skill(x_player.id, x_cryp.id, None, Skill::Corrupt).unwrap(); + game.add_skill(x_player.id, x_construct.id, None, Skill::Corrupt).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); - assert!(game.cryp_by_id(x_cryp.id).unwrap().affected(Effect::Corrupt)); + assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Corrupt)); // attack and receive debuff - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); - assert!(game.cryp_by_id(y_cryp.id).unwrap().affected(Effect::Corruption)); + assert!(game.construct_by_id(y_construct.id).unwrap().affected(Effect::Corruption)); } #[test] @@ -1208,21 +1208,21 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); - game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Scatter); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Scatter); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Scatter).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Scatter).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } // apply buff - game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Scatter).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Scatter).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); - assert!(game.cryp_by_id(x_cryp.id).unwrap().affected(Effect::Scatter)); + assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Scatter)); let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap(); match event { @@ -1237,13 +1237,13 @@ mod tests { } // attack and receive scatter hit - game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::Attack).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); let Resolution { source: _, target, event } = game.resolved.pop().unwrap(); - assert_eq!(target.id, y_cryp.id); + assert_eq!(target.id, y_construct.id); match event { Event::Damage { amount, skill: _, mitigation: _, colour: _} => assert_eq!(amount, 256.pct(Skill::Attack.multiplier()) >> 1), @@ -1258,30 +1258,30 @@ mod tests { // let x_player = game.players[0].clone(); // let y_player = game.players[1].clone(); - // let x_cryp = x_player.cryps[0].clone(); - // let y_cryp = y_player.cryps[0].clone(); + // let x_construct = x_player.constructs[0].clone(); + // let y_construct = y_player.constructs[0].clone(); - // game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Hostility); + // game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Hostility); - // while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Hostility).is_some() { - // game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + // while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Hostility).is_some() { + // game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); // } // // apply buff - // game.add_skill(x_player.id, x_cryp.id, Some(x_cryp.id), Skill::Hostility).unwrap(); + // game.add_skill(x_player.id, x_construct.id, Some(x_construct.id), Skill::Hostility).unwrap(); // game.player_ready(x_player.id).unwrap(); // game.player_ready(y_player.id).unwrap(); // game = game.resolve_phase_start(); - // assert!(game.cryp_by_id(x_cryp.id).unwrap().affected(Effect::Hostility)); + // assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Hostility)); // // attack and receive debuff - // game.add_skill(y_player.id, y_cryp.id, Some(x_cryp.id), Skill::TestAttack).unwrap(); + // game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestAttack).unwrap(); // game.player_ready(x_player.id).unwrap(); // game.player_ready(y_player.id).unwrap(); // game = game.resolve_phase_start(); // info!("{:#?}", game); - // assert!(game.cryp_by_id(y_cryp.id).unwrap().affected(Effect::Hatred)); + // assert!(game.construct_by_id(y_construct.id).unwrap().affected(Effect::Hatred)); // } #[test] @@ -1291,21 +1291,21 @@ mod tests { let i_player = game.players[0].clone(); let x_player = game.players[1].clone(); - let i_cryp = i_player.cryps[0].clone(); - let j_cryp = i_player.cryps[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = x_player.cryps[1].clone(); + let i_construct = i_player.constructs[0].clone(); + let j_construct = i_player.constructs[1].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = x_player.constructs[1].clone(); - game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Ruin); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Ruin); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Ruin).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Ruin).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.add_skill(i_player.id, i_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::Ruin).unwrap(); - game.add_skill(x_player.id, y_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); + game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Ruin).unwrap(); + game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); game.player_ready(i_player.id).unwrap(); game.player_ready(x_player.id).unwrap(); @@ -1316,7 +1316,7 @@ mod tests { .into_iter() .filter(|r| { let Resolution { source, target: _, event } = r; - match source.id == x_cryp.id { + match source.id == x_construct.id { true => match event { Event::Effect { effect, duration, skill: _ } => { assert!(*effect == Effect::Stun); @@ -1341,21 +1341,21 @@ mod tests { let i_player = game.players[0].clone(); let x_player = game.players[1].clone(); - let i_cryp = i_player.cryps[0].clone(); - let j_cryp = i_player.cryps[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = x_player.cryps[1].clone(); + let i_construct = i_player.constructs[0].clone(); + let j_construct = i_player.constructs[1].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = x_player.constructs[1].clone(); - game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Taunt); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Taunt); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Taunt).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Taunt).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.add_skill(i_player.id, i_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::Taunt).unwrap(); - game.add_skill(x_player.id, y_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); + game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Taunt).unwrap(); + game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); game.player_ready(i_player.id).unwrap(); game.player_ready(x_player.id).unwrap(); @@ -1365,8 +1365,8 @@ mod tests { assert!(game.resolved.len() == 5); while let Some(r) = game.resolved.pop() { let Resolution { source , target, event: _ } = r; - if [i_cryp.id, j_cryp.id].contains(&source.id) { - assert!(target.id == x_cryp.id); + if [i_construct.id, j_construct.id].contains(&source.id) { + assert!(target.id == x_construct.id); } } } @@ -1378,15 +1378,15 @@ mod tests { let i_player = game.players[0].clone(); let x_player = game.players[1].clone(); - let i_cryp = i_player.cryps[0].clone(); - let j_cryp = i_player.cryps[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = x_player.cryps[1].clone(); + let i_construct = i_player.constructs[0].clone(); + let j_construct = i_player.constructs[1].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = x_player.constructs[1].clone(); - game.add_skill(i_player.id, i_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(x_player.id, y_cryp.id, Some(i_cryp.id), Skill::TestTouch).unwrap(); + game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); game.player_ready(i_player.id).unwrap(); game.player_ready(x_player.id).unwrap(); @@ -1396,17 +1396,17 @@ mod tests { assert!([Phase::Skill, Phase::Finish].contains(&game.phase)); - // kill a cryp - game.player_by_id(i_player.id).unwrap().cryp_by_id(i_cryp.id).unwrap().green_life.reduce(u64::max_value()); + // kill a construct + game.player_by_id(i_player.id).unwrap().construct_by_id(i_construct.id).unwrap().green_life.reduce(u64::max_value()); assert!(game.player_by_id(i_player.id).unwrap().skills_required() == 1); assert!(game.player_by_id(x_player.id).unwrap().skills_required() == 2); // add some more skills - game.add_skill(i_player.id, j_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(x_player.id, x_cryp.id, Some(j_cryp.id), Skill::TestTouch).unwrap(); - game.add_skill(x_player.id, y_cryp.id, Some(j_cryp.id), Skill::TestTouch).unwrap(); - assert!(game.add_skill(x_player.id, x_cryp.id, Some(i_cryp.id), Skill::TestTouch).is_err()); + game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(j_construct.id), Skill::TestTouch).unwrap(); + game.add_skill(x_player.id, y_construct.id, Some(j_construct.id), Skill::TestTouch).unwrap(); + assert!(game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TestTouch).is_err()); game.player_ready(i_player.id).unwrap(); game.player_ready(x_player.id).unwrap(); @@ -1426,33 +1426,33 @@ mod tests { let x_player = game.players[0].clone(); let y_player = game.players[1].clone(); - let x_cryp = x_player.cryps[0].clone(); - let y_cryp = y_player.cryps[0].clone(); + let x_construct = x_player.constructs[0].clone(); + let y_construct = y_player.constructs[0].clone(); - // make the purify cryp super fast so it beats out decay - game.cryp_by_id(y_cryp.id).unwrap().speed.force(10000000); + // make the purify construct super fast so it beats out decay + game.construct_by_id(y_construct.id).unwrap().speed.force(10000000); - game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Decay); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Decay).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Decay); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Decay).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::Siphon); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::Siphon).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::Siphon); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Siphon).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.cryp_by_id(y_cryp.id).unwrap().learn_mut(Skill::Purify); - while game.cryp_by_id(y_cryp.id).unwrap().skill_on_cd(Skill::Purify).is_some() { - game.cryp_by_id(y_cryp.id).unwrap().reduce_cooldowns(); + game.construct_by_id(y_construct.id).unwrap().learn_mut(Skill::Purify); + while game.construct_by_id(y_construct.id).unwrap().skill_on_cd(Skill::Purify).is_some() { + game.construct_by_id(y_construct.id).unwrap().reduce_cooldowns(); } // apply buff - game.add_skill(x_player.id, x_cryp.id, Some(y_cryp.id), Skill::Decay).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Decay).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); - assert!(game.cryp_by_id(y_cryp.id).unwrap().affected(Effect::Decay)); + assert!(game.construct_by_id(y_construct.id).unwrap().affected(Effect::Decay)); let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap(); match event { @@ -1463,7 +1463,7 @@ mod tests { game.resolved.clear(); // remove - game.add_skill(y_player.id, y_cryp.id, Some(y_cryp.id), Skill::Purify).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::Purify).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); @@ -1476,14 +1476,14 @@ mod tests { } }; - game.add_skill(y_player.id, x_cryp.id, Some(y_cryp.id), Skill::Siphon).unwrap(); + game.add_skill(y_player.id, x_construct.id, Some(y_construct.id), Skill::Siphon).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); game.resolved.clear(); - game.add_skill(y_player.id, y_cryp.id, Some(y_cryp.id), Skill::Purify).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::Purify).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); diff --git a/server/src/instance.rs b/server/src/instance.rs index a35192bf..d2de34ea 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -16,7 +16,7 @@ use chrono::Duration; use rpc::{InstanceLobbyParams, InstanceJoinParams, InstanceReadyParams, InstanceStateParams}; use account::Account; use player::{Player, player_create, player_get, player_global_update}; -use cryp::{Cryp, cryp_get}; +use construct::{Construct, construct_get}; use mob::{instance_mobs}; use game::{Game, Phase, game_get, game_write}; use item::{Item}; @@ -144,8 +144,8 @@ impl Instance { self.open = false; self.players = iter::repeat_with(|| { let bot_id = Uuid::new_v4(); - let cryps = instance_mobs(bot_id); - let mut p = Player::new(bot_id, &name(), cryps).set_bot(true); + let constructs = instance_mobs(bot_id); + let mut p = Player::new(bot_id, &name(), constructs).set_bot(true); p.set_ready(true); p }) @@ -202,8 +202,8 @@ impl Instance { self.players[i].set_ready(v); // start the game even if afk noobs have no skills - if !self.phase_timed_out() && self.players[i].cryps.iter().all(|c| c.skills.len() == 0) { - return Err(err_msg("your cryps have no skills")); + if !self.phase_timed_out() && self.players[i].constructs.iter().all(|c| c.skills.len() == 0) { + return Err(err_msg("your constructs have no skills")); } // create a game object if both players are ready @@ -247,7 +247,7 @@ impl Instance { game .set_player_num(2) - .set_player_cryps(3) + .set_player_constructs(3) .set_instance(self.id); // create the initiators player @@ -472,17 +472,17 @@ impl Instance { Ok(self) } - pub fn vbox_apply(mut self, account: Uuid, index: usize, cryp_id: Uuid) -> Result { + pub fn vbox_apply(mut self, account: Uuid, index: usize, construct_id: Uuid) -> Result { self.vbox_action_allowed(account)?; self.account_player(account)? - .vbox_apply(index, cryp_id)?; + .vbox_apply(index, construct_id)?; Ok(self) } - pub fn vbox_unequip(mut self, account: Uuid, target: Item, cryp_id: Uuid) -> Result { + pub fn vbox_unequip(mut self, account: Uuid, target: Item, construct_id: Uuid) -> Result { self.vbox_action_allowed(account)?; self.account_player(account)? - .vbox_unequip(target, cryp_id)?; + .vbox_unequip(target, construct_id)?; Ok(self) } } @@ -627,7 +627,7 @@ pub fn instance_new(params: InstanceLobbyParams, tx: &mut Transaction, account: }; instance = instance_create(tx, instance)?; - let join_params = InstanceJoinParams { instance_id: instance.id, cryp_ids: params.cryp_ids }; + let join_params = InstanceJoinParams { instance_id: instance.id, construct_ids: params.construct_ids }; instance_join(join_params, tx, account) } @@ -635,16 +635,16 @@ pub fn instance_new(params: InstanceLobbyParams, tx: &mut Transaction, account: pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account: &Account) -> Result { let mut instance = instance_get(tx, params.instance_id)?; - let cryps = params.cryp_ids + let constructs = params.construct_ids .iter() - .map(|id| cryp_get(tx, *id, account.id)) - .collect::, Error>>()?; + .map(|id| construct_get(tx, *id, account.id)) + .collect::, Error>>()?; - if cryps.len() != 3 { + if constructs.len() != 3 { return Err(format_err!("incorrect player size. ({:})", 3)); } - let player = player_create(tx, Player::new(account.id, &account.name, cryps), instance.id, account)?; + let player = player_create(tx, Player::new(account.id, &account.name, constructs), instance.id, account)?; instance.add_player(player)?; @@ -736,8 +736,8 @@ mod tests { .add_bots(); let player_account = Uuid::new_v4(); - let cryps = instance_mobs(player_account); - let player = Player::new(player_account, &"test".to_string(), cryps).set_bot(true); + let constructs = instance_mobs(player_account); + let player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true); let player_id = player.id; instance.add_player(player).expect("could not add player"); @@ -754,8 +754,8 @@ mod tests { fn instance_bot_vbox_test() { let instance = Instance::new(); let player_account = Uuid::new_v4(); - let cryps = instance_mobs(player_account); - let _player = Player::new(player_account, &"test".to_string(), cryps).set_bot(true); + let constructs = instance_mobs(player_account); + let _player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true); } #[test] @@ -767,16 +767,16 @@ mod tests { assert_eq!(instance.max_players, 2); let player_account = Uuid::new_v4(); - let cryps = instance_mobs(player_account); - let player = Player::new(player_account, &"a".to_string(), cryps); + let constructs = instance_mobs(player_account); + let player = Player::new(player_account, &"a".to_string(), constructs); let a_id = player.id; instance.add_player(player).expect("could not add player"); assert!(!instance.can_start()); let player_account = Uuid::new_v4(); - let cryps = instance_mobs(player_account); - let player = Player::new(player_account, &"b".to_string(), cryps); + let constructs = instance_mobs(player_account); + let player = Player::new(player_account, &"b".to_string(), constructs); let b_id = player.id; instance.add_player(player).expect("could not add player"); @@ -806,16 +806,16 @@ mod tests { .expect("could not create instance"); let player_account = Uuid::new_v4(); - let cryps = instance_mobs(player_account); - let player = Player::new(player_account, &"a".to_string(), cryps); + let constructs = instance_mobs(player_account); + let player = Player::new(player_account, &"a".to_string(), constructs); let a_id = player.id; instance.add_player(player).expect("could not add player"); assert!(!instance.can_start()); let player_account = Uuid::new_v4(); - let cryps = instance_mobs(player_account); - let player = Player::new(player_account, &"b".to_string(), cryps); + let constructs = instance_mobs(player_account); + let player = Player::new(player_account, &"b".to_string(), constructs); let b_id = player.id; instance.add_player(player).expect("could not add player"); diff --git a/server/src/item.rs b/server/src/item.rs index f72f8dbd..3724a547 100644 --- a/server/src/item.rs +++ b/server/src/item.rs @@ -1,6 +1,6 @@ use skill::{Skill, Effect, Colour}; use spec::{Spec}; -use cryp::{Colours}; +use construct::{Colours}; #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] pub enum Item { @@ -277,46 +277,46 @@ impl Item { 100 - self.into_skill().unwrap().effect().first().unwrap().get_multiplier()), - Item::Stun => format!("Stun target cryp for {:?}T", + Item::Stun => format!("Stun target construct for {:?}T", self.into_skill().unwrap().effect().first().unwrap().get_duration()), - Item::Buff => format!("Increase target cryp red damage and speed by {:?}%", + Item::Buff => format!("Increase target construct red damage and speed by {:?}%", self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100), - Item::Debuff => format!("Slow target cryp speed by {:?}%", + Item::Debuff => format!("Slow target construct speed by {:?}%", 100 - self.into_skill().unwrap().effect().first().unwrap().get_multiplier()), // specs // Base Item::Damage => format!("Base ITEM for increased DAMAGE. DAMAGE determines the power of your SKILLS."), Item::Life => format!("Base ITEM for increased LIFE. - When your CRYP reaches 0 GreenLife it becomes KO and cannot cast SKILLS."), + When your CONSTRUCT reaches 0 GreenLife it becomes KO and cannot cast SKILLS."), Item::Speed => format!("Base ITEM for increased SPEED. SPEED determines the order in which skills resolve."), // Lifes Upgrades - Item::GreenLifeI => format!("Increases CRYP GreenLife. - When your CRYP reaches 0 GreenLife it becomes KO and cannot cast SKILLS."), - Item::RedLifeI => format!("Increases CRYP RedLife. - Red damage dealt to your cryp reduces RedLife before GreenLife."), - Item::BlueLifeI => format!("Increases CRYP BlueLife. - Blue damage dealt to your cryp reduces BlueLife before GreenLife."), - Item::GRLI => format!("Increases CRYP GreenLife + RedLife"), - Item::GBLI => format!("Increases CRYP GreenLife + BlueLife"), - Item::RBLI => format!("Increases CRYP RedLife + BlueLife"), + Item::GreenLifeI => format!("Increases CONSTRUCT GreenLife. + When your CONSTRUCT reaches 0 GreenLife it becomes KO and cannot cast SKILLS."), + Item::RedLifeI => format!("Increases CONSTRUCT RedLife. + Red damage dealt to your construct reduces RedLife before GreenLife."), + Item::BlueLifeI => format!("Increases CONSTRUCT BlueLife. + Blue damage dealt to your construct reduces BlueLife before GreenLife."), + Item::GRLI => format!("Increases CONSTRUCT GreenLife + RedLife"), + Item::GBLI => format!("Increases CONSTRUCT GreenLife + BlueLife"), + Item::RBLI => format!("Increases CONSTRUCT RedLife + BlueLife"), // Damage Upgrades - Item::RedDamageI => format!("Increases CRYP RedDamage."), - Item::BlueDamageI => format!("Increases CRYP BlueDamage."), - Item::GreenDamageI => format!("Increases CRYP GreenDamage."), - Item::GRDI => format!("Increases CRYP GreenDamage + RedDamage."), - Item::GBDI => format!("Increases CRYP GreenDamage + BlueDamage."), - Item::RBDI => format!("Increases CRYP RedDamage + BlueDamage."), + Item::RedDamageI => format!("Increases CONSTRUCT RedDamage."), + Item::BlueDamageI => format!("Increases CONSTRUCT BlueDamage."), + Item::GreenDamageI => format!("Increases CONSTRUCT GreenDamage."), + Item::GRDI => format!("Increases CONSTRUCT GreenDamage + RedDamage."), + Item::GBDI => format!("Increases CONSTRUCT GreenDamage + BlueDamage."), + Item::RBDI => format!("Increases CONSTRUCT RedDamage + BlueDamage."), // Speed Upgrades - Item::RedSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), - Item::BlueSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), - Item::GreenSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), - Item::GRSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), - Item::GBSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), - Item::RBSpeedI => format!("Increases CRYP SPEED and provides COLOUR BONUSES"), + Item::RedSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), + Item::BlueSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), + Item::GreenSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), + Item::GRSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), + Item::GBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), + Item::RBSpeedI => format!("Increases CONSTRUCT SPEED and provides COLOUR BONUSES"), // Skills <- need to move effect mulltipliers into skills Item::Amplify => format!("Increase red and blue power by {:?}%. Lasts {:?}T", @@ -324,7 +324,7 @@ impl Item { self.into_skill().unwrap().effect().first().unwrap().get_duration()), Item::Banish => format!("Banish target for {:?}T. - Banished cryps are immune to all skills and effects.", + Banished constructs are immune to all skills and effects.", self.into_skill().unwrap().effect().first().unwrap().get_duration()), Item::Blast => format!("Deals blue damage {:?}% blue power.", self.into_skill().unwrap().multiplier()), @@ -333,7 +333,7 @@ impl Item { "Hits twice for red and blue damage. Damage is random 0 to 30% + {:?}% red and blue power.", self.into_skill().unwrap().multiplier()), - Item::Clutch => format!("Cryp cannot be KO'd while active. + Item::Clutch => format!("Construct cannot be KO'd while active. Additionally provides immunity to disables."), Item::Corrupt => format!( @@ -370,7 +370,7 @@ impl Item { Item::Heal => format!("Heals for {:?}% green power.", self.into_skill().unwrap().multiplier()), Item::Hex => format!("Blue based skill that applies Hex for {:?}T. \ - Hexed targets cannot cast any skills.", + Hexed targets cannot cast any skills.", self.into_skill().unwrap().effect().first().unwrap().get_duration()), @@ -389,10 +389,10 @@ impl Item { "Self targetting skill. Recharges RedLife for", self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().effect().first().unwrap().get_duration(), - "If a red skill is parried the cryp will riposte the source dealing red damage", + "If a red skill is parried the construct will riposte the source dealing red damage", Skill::Riposte.multiplier()), - Item::Purge => format!("Remove buffs from target cryp"), + Item::Purge => format!("Remove buffs from target construct"), Item::Purify => format!( "Remove debuffs and heals for {:?}% green power per debuff removed.", @@ -406,11 +406,11 @@ impl Item { self.into_skill().unwrap().multiplier()), Item::Ruin => format!( - "Team wide Stun for {:?}T. Stunned cryps are unable to cast skills.", + "Team wide Stun for {:?}T. Stunned constructs are unable to cast skills.", self.into_skill().unwrap().effect().first().unwrap().get_duration()), - + Item::Scatter => format!( - "Caster links with target. Linked cryps split incoming damage evenly. Recharges target blue shield {:?}% of blue power", + "Caster links with target. Linked constructs split incoming damage evenly. Recharges target blue shield {:?}% of blue power", self.into_skill().unwrap().multiplier()), Item::Silence => format!( diff --git a/server/src/main.rs b/server/src/main.rs index 39e51e00..bda90620 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,7 +1,7 @@ extern crate rand; extern crate uuid; extern crate tungstenite; -extern crate bcrypt; +extern crate bconstructt; extern crate chrono; extern crate dotenv; @@ -18,7 +18,7 @@ extern crate fern; #[macro_use] extern crate log; mod account; -mod cryp; +mod construct; mod game; mod instance; mod item; @@ -51,7 +51,7 @@ fn setup_logger() -> Result<(), fern::InitError> { .level_for("tungstenite", log::LevelFilter::Info) .level(log::LevelFilter::Debug) .chain(std::io::stdout()) - .chain(fern::log_file("log/cryps.log")?) + .chain(fern::log_file("log/constructs.log")?) .apply()?; Ok(()) } diff --git a/server/src/mob.rs b/server/src/mob.rs index d04109c7..e97e1c86 100644 --- a/server/src/mob.rs +++ b/server/src/mob.rs @@ -4,10 +4,10 @@ use rand::prelude::*; use rand::distributions::Alphanumeric; use std::iter; -use cryp::{Cryp}; +use construct::{Construct}; use skill::{Skill}; -pub fn generate_mob() -> Cryp { +pub fn generate_mob() -> Construct { let mut rng = thread_rng(); let name: String = iter::repeat(()) @@ -15,86 +15,86 @@ pub fn generate_mob() -> Cryp { .take(8) .collect(); - let mob = Cryp::new() + let mob = Construct::new() .named(&name); return mob; } -// fn quick_game(player_size: usize) -> Vec { +// fn quick_game(player_size: usize) -> Vec { // iter::repeat_with(|| // generate_mob() // .set_account(Uuid::nil()) // .learn(Skill::Attack)) // .take(player_size) -// .collect::>() +// .collect::>() // } -pub fn instance_mobs(player_id: Uuid) -> Vec { +pub fn instance_mobs(player_id: Uuid) -> Vec { iter::repeat_with(|| generate_mob() .set_account(player_id)) // .learn(Skill::Attack)) .take(3) - .collect::>() + .collect::>() } -// fn zone_3v2_attack(player_lvl: u8) -> Vec { -// let x = Cryp::new() +// fn zone_3v2_attack(player_lvl: u8) -> Vec { +// let x = Construct::new() // .named(&"hench".to_string()) // .learn(Skill::Attack); -// let y = Cryp::new() +// let y = Construct::new() // .named(&"bench".to_string()) // .learn(Skill::Attack); // return vec![x, y]; // } -// fn zone_2v2_caster(player_lvl: u8) -> Vec { -// let x = Cryp::new() +// fn zone_2v2_caster(player_lvl: u8) -> Vec { +// let x = Construct::new() // .named(&"robe".to_string()) // .learn(Skill::Blast); -// let y = Cryp::new() +// let y = Construct::new() // .named(&"wizard hat".to_string()) // .learn(Skill::Blast); // return vec![x, y]; // } -// fn zone_3v3_melee_miniboss(player_lvl: u8) -> Vec { -// let x = Cryp::new() +// fn zone_3v3_melee_miniboss(player_lvl: u8) -> Vec { +// let x = Construct::new() // .named(&"jungle juice".to_string()) // .learn(Skill::Attack); -// let y = Cryp::new() +// let y = Construct::new() // .named(&"bamboo basher".to_string()) // .learn(Skill::Attack) // .learn(Skill::Stun); -// let z = Cryp::new() +// let z = Construct::new() // .named(&"lemongrass tea".to_string()) // .learn(Skill::Attack); // return vec![x, y, z]; // } -// fn zone_3v3_healer_boss(player_lvl: u8) -> Vec { -// let x = Cryp::new() +// fn zone_3v3_healer_boss(player_lvl: u8) -> Vec { +// let x = Construct::new() // .named(&"coinage".to_string()) // .learn(Skill::Attack) // .learn(Skill::Parry) // .learn(Skill::Block); -// let y = Cryp::new() +// let y = Construct::new() // .named(&"wololo".to_string()) // // big strong // // .learn(Skill::Blast) // .learn(Skill::Heal) // .learn(Skill::Triage); -// let z = Cryp::new() +// let z = Construct::new() // .named(&"quarry".to_string()) // .learn(Skill::Attack) // .learn(Skill::Parry) @@ -104,22 +104,22 @@ pub fn instance_mobs(player_id: Uuid) -> Vec { // } -// pub fn generate_mob_player(mode: GameMode, cryps: &Vec) -> Player { +// pub fn generate_mob_player(mode: GameMode, constructs: &Vec) -> Player { // let mut mob_player = Player::new(Uuid::nil()); -// let cryp_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl; -// let player_size = cryps.len(); +// let construct_lvl = constructs.iter().max_by_key(|c| c.lvl).unwrap().lvl; +// let player_size = constructs.len(); // let mobs = match mode { -// GameMode::Normal => quick_game(cryp_lvl, player_size), -// GameMode::Zone3v2Attack => zone_3v2_attack(cryp_lvl), -// GameMode::Zone2v2Caster => zone_2v2_caster(cryp_lvl), -// GameMode::Zone3v3MeleeMiniboss => zone_3v3_melee_miniboss(cryp_lvl), -// GameMode::Zone3v3HealerBoss => zone_3v3_healer_boss(cryp_lvl), +// GameMode::Normal => quick_game(construct_lvl, player_size), +// GameMode::Zone3v2Attack => zone_3v2_attack(construct_lvl), +// GameMode::Zone2v2Caster => zone_2v2_caster(construct_lvl), +// GameMode::Zone3v3MeleeMiniboss => zone_3v3_melee_miniboss(construct_lvl), +// GameMode::Zone3v3HealerBoss => zone_3v3_healer_boss(construct_lvl), // _ => panic!("{:?} not handled for pve mobs", mode), // }; -// mob_player.set_cryps(mobs); +// mob_player.set_constructs(mobs); // return mob_player; diff --git a/server/src/player.rs b/server/src/player.rs index 50addc8d..7ff816ff 100644 --- a/server/src/player.rs +++ b/server/src/player.rs @@ -9,10 +9,10 @@ use failure::Error; use failure::err_msg; use account::Account; -use cryp::{Cryp, Colours, cryp_get}; +use construct::{Construct, Colours, construct_get}; use vbox::{Vbox}; use item::{Item, ItemEffect}; -use rpc::{PlayerCrypsSetParams}; +use rpc::{PlayerConstructsSetParams}; use instance::{Instance}; use skill::{Effect}; @@ -30,20 +30,20 @@ pub struct Player { pub name: String, pub vbox: Vbox, pub score: Score, - pub cryps: Vec, + pub constructs: Vec, pub bot: bool, pub ready: bool, pub warnings: u8, } impl Player { - pub fn new(account: Uuid, name: &String, cryps: Vec) -> Player { + pub fn new(account: Uuid, name: &String, constructs: Vec) -> Player { Player { id: account, name: name.clone(), vbox: Vbox::new(), score: Score { wins: 0, losses: 0 }, - cryps, + constructs, bot: false, ready: false, warnings: 0, @@ -66,8 +66,8 @@ impl Player { } pub fn forfeit(&mut self) -> &mut Player { - for cryp in self.cryps.iter_mut() { - cryp.force_ko(); + for construct in self.constructs.iter_mut() { + construct.force_ko(); } self } @@ -84,19 +84,19 @@ impl Player { self } - pub fn cryp_get(&mut self, id: Uuid) -> Result<&mut Cryp, Error> { - self.cryps.iter_mut().find(|c| c.id == id).ok_or(err_msg("cryp not found")) + pub fn construct_get(&mut self, id: Uuid) -> Result<&mut Construct, Error> { + self.constructs.iter_mut().find(|c| c.id == id).ok_or(err_msg("construct not found")) } pub fn autobuy(&mut self) -> &mut Player { let mut rng = thread_rng(); - // first check if any cryps have no skills + // first check if any constructs have no skills // if there is one find an item in vbox that gives a skill - while let Some(c) = self.cryps.iter().position(|c| c.skills.len() == 0) { + while let Some(c) = self.constructs.iter().position(|c| c.skills.len() == 0) { if let Some(s) = self.vbox.bound.iter().position(|v| v.into_skill().is_some()) { - let cryp_id = self.cryps[c].id; - self.vbox_apply(s, cryp_id).expect("could not apply"); + let construct_id = self.constructs[c].id; + self.vbox_apply(s, construct_id).expect("could not apply"); continue; } info!("no skills available..."); @@ -106,23 +106,23 @@ impl Player { // inb4 montecarlo gan loop { - let (target_cryp_i, target_cryp_id) = match self.cryps.iter().any(|c| c.skills.len() < 3) { + let (target_construct_i, target_construct_id) = match self.constructs.iter().any(|c| c.skills.len() < 3) { true => { - let mut target_cryp_i = 0; - for (j, c) in self.cryps.iter().enumerate() { - if c.skills.len() < self.cryps[target_cryp_i].skills.len() { - target_cryp_i = j; + let mut target_construct_i = 0; + for (j, c) in self.constructs.iter().enumerate() { + if c.skills.len() < self.constructs[target_construct_i].skills.len() { + target_construct_i = j; } } - (target_cryp_i, self.cryps[target_cryp_i].id) + (target_construct_i, self.constructs[target_construct_i].id) }, false => { let i = rng.gen_range(0, 3); - (i, self.cryps[i].id) + (i, self.constructs[i].id) }, }; - let needs_skills = self.cryps[target_cryp_i].skills.len() < 3; + let needs_skills = self.constructs[target_construct_i].skills.len() < 3; let group_i = match needs_skills { true => 1, false => 2, @@ -161,7 +161,7 @@ impl Player { // first 2 colours can be whatever self.vbox_combine(vec![0, 1, combo_i]).ok(); let item_i = self.vbox.bound.len() - 1; - self.vbox_apply(item_i, target_cryp_id).ok(); + self.vbox_apply(item_i, target_construct_id).ok(); } return self; @@ -188,7 +188,7 @@ impl Player { Ok(self) } - pub fn vbox_apply(&mut self, index: usize, cryp_id: Uuid) -> Result<&mut Player, Error> { + pub fn vbox_apply(&mut self, index: usize, construct_id: Uuid) -> Result<&mut Player, Error> { if self.vbox.bound.get(index).is_none() { return Err(format_err!("no item at index {:?}", index)); } @@ -198,31 +198,31 @@ impl Player { match item.effect() { Some(ItemEffect::Skill) => { let skill = item.into_skill().ok_or(format_err!("item {:?} has no associated skill", item))?; - let cryp = self.cryp_get(cryp_id)?; + let construct = self.construct_get(construct_id)?; // done here because i teach them a tonne of skills for tests let max_skills = 3; - if cryp.skills.len() >= max_skills { - return Err(format_err!("cryp at max skills ({:?})", max_skills)); + if construct.skills.len() >= max_skills { + return Err(format_err!("construct at max skills ({:?})", max_skills)); } - if cryp.knows(skill) { - return Err(format_err!("cryp already knows skill ({:?})" , skill)); + if construct.knows(skill) { + return Err(format_err!("construct already knows skill ({:?})" , skill)); } - cryp.learn_mut(skill); + construct.learn_mut(skill); }, Some(ItemEffect::Spec) => { let spec = item.into_spec().ok_or(format_err!("item {:?} has no associated spec", item))?; - let cryp = self.cryp_get(cryp_id)?; - cryp.spec_add(spec)?; + let construct = self.construct_get(construct_id)?; + construct.spec_add(spec)?; }, - None => return Err(err_msg("item has no effect on cryps")), + None => return Err(err_msg("item has no effect on constructs")), } // now the item has been applied // recalculate the stats of the whole player - let player_colours = self.cryps.iter().fold(Colours::new(), |tc, c| { + let player_colours = self.constructs.iter().fold(Colours::new(), |tc, c| { Colours { red: tc.red + c.colours.red, green: tc.green + c.colours.green, @@ -230,14 +230,14 @@ impl Player { } }); - for cryp in self.cryps.iter_mut() { - cryp.apply_modifiers(&player_colours); + for construct in self.constructs.iter_mut() { + construct.apply_modifiers(&player_colours); } Ok(self) } - pub fn vbox_unequip(&mut self, target: Item, cryp_id: Uuid) -> Result<&mut Player, Error> { + pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid) -> Result<&mut Player, Error> { if self.vbox.bound.len() >= 9 { return Err(err_msg("too many items bound")); } @@ -245,20 +245,20 @@ impl Player { match target.effect() { Some(ItemEffect::Skill) => { let skill = target.into_skill().ok_or(format_err!("item {:?} has no associated skill", target))?; - let cryp = self.cryp_get(cryp_id)?; - cryp.forget(skill)?; + let construct = self.construct_get(construct_id)?; + construct.forget(skill)?; }, Some(ItemEffect::Spec) => { let spec = target.into_spec().ok_or(format_err!("item {:?} has no associated spec", target))?; - let cryp = self.cryp_get(cryp_id)?; - cryp.spec_remove(spec)?; + let construct = self.construct_get(construct_id)?; + construct.spec_remove(spec)?; }, - None => return Err(err_msg("item has no effect on cryps")), + None => return Err(err_msg("item has no effect on constructs")), } // now the item has been applied // recalculate the stats of the whole player - let player_colours = self.cryps.iter().fold(Colours::new(), |tc, c| { + let player_colours = self.constructs.iter().fold(Colours::new(), |tc, c| { Colours { red: tc.red + c.colours.red, green: tc.green + c.colours.green, @@ -266,8 +266,8 @@ impl Player { } }); - for cryp in self.cryps.iter_mut() { - cryp.apply_modifiers(&player_colours); + for construct in self.constructs.iter_mut() { + construct.apply_modifiers(&player_colours); } self.vbox.bound.push(target); @@ -278,27 +278,27 @@ impl Player { // GAME METHODS pub fn skills_required(&self) -> usize { - let required = self.cryps.iter() + let required = self.constructs.iter() .filter(|c| !c.is_ko()) .filter(|c| c.available_skills().len() > 0) - .collect::>().len(); + .collect::>().len(); // info!("{:} requires {:} skills this turn", self.id, required); return required; } - pub fn taunting(&self) -> Option<&Cryp> { - self.cryps.iter() + pub fn taunting(&self) -> Option<&Construct> { + self.constructs.iter() .find(|c| c.affected(Effect::Taunt)) } - pub fn set_cryps(&mut self, mut cryps: Vec) -> &mut Player { - cryps.sort_unstable_by_key(|c| c.id); - self.cryps = cryps; + pub fn set_constructs(&mut self, mut constructs: Vec) -> &mut Player { + constructs.sort_unstable_by_key(|c| c.id); + self.constructs = constructs; self } - pub fn cryp_by_id(&mut self, id: Uuid) -> Option<&mut Cryp> { - self.cryps.iter_mut().find(|c| c.id == id) + pub fn construct_by_id(&mut self, id: Uuid) -> Option<&mut Construct> { + self.constructs.iter_mut().find(|c| c.id == id) } } @@ -320,7 +320,7 @@ pub fn player_get(tx: &mut Transaction, account_id: Uuid, instance_id: Uuid) -> None => return Err(err_msg("player not found")), }; - // tells from_slice to cast into a cryp + // tells from_slice to cast into a construct let bytes: Vec = returned.get("data"); let data = from_slice::(&bytes)?; @@ -386,24 +386,24 @@ pub fn player_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> { return Ok(()); } -pub fn player_mm_cryps_set(params: PlayerCrypsSetParams, tx: &mut Transaction, account: &Account) -> Result { - if params.cryp_ids.len() != 3 { +pub fn player_mm_constructs_set(params: PlayerConstructsSetParams, tx: &mut Transaction, account: &Account) -> Result { + if params.construct_ids.len() != 3 { return Err(err_msg("player size is 3")); } - let cryps = params.cryp_ids + let constructs = params.construct_ids .iter() - .map(|id| cryp_get(tx, *id, account.id)) - .collect::, Error>>()?; + .map(|id| construct_get(tx, *id, account.id)) + .collect::, Error>>()?; let player = match player_get(tx, account.id, Uuid::nil()) { Ok(mut p) => { - p.cryps = cryps; + p.constructs = constructs; p.vbox = Vbox::new(); player_global_update(tx, p, false)? }, Err(_) => { - player_create(tx, Player::new(account.id, &account.name, cryps), Uuid::nil(), &account)? + player_create(tx, Player::new(account.id, &account.name, constructs), Uuid::nil(), &account)? } }; @@ -419,12 +419,12 @@ mod tests { #[test] fn player_bot_vbox_test() { let player_account = Uuid::new_v4(); - let cryps = instance_mobs(player_account); - let mut player = Player::new(player_account, &"test".to_string(), cryps).set_bot(true); + let constructs = instance_mobs(player_account); + let mut player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true); player.vbox.fill(); player.autobuy(); - assert!(player.cryps.iter().all(|c| c.skills.len() >= 1)); + assert!(player.constructs.iter().all(|c| c.skills.len() >= 1)); } } \ No newline at end of file diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 6b38c53a..464ff017 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -16,12 +16,12 @@ use failure::Error; use failure::err_msg; use net::Db; -use cryp::{Cryp, cryp_spawn}; +use construct::{Construct, construct_spawn}; use game::{Game, game_state, game_skill, game_ready}; -use account::{Account, account_create, account_login, account_from_token, account_cryps, account_instances}; +use account::{Account, account_create, account_login, account_from_token, account_constructs, account_instances}; use skill::{Skill}; use spec::{Spec}; -use player::{Score, player_mm_cryps_set}; +use player::{Score, player_mm_constructs_set}; use instance::{Instance, instance_state, instance_new, instance_ready, instance_join}; use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim, vbox_unequip}; use item::{Item, ItemInfoCtr, item_info}; @@ -71,11 +71,11 @@ impl Rpc { "account_login" => Rpc::account_login(data, &mut tx, client), // auth methods - "account_cryps" => Rpc::account_cryps(data, &mut tx, account.unwrap(), client), + "account_constructs" => Rpc::account_constructs(data, &mut tx, account.unwrap(), client), "account_instances" => Rpc::account_instances(data, &mut tx, account.unwrap(), client), // "account_zone" => Rpc::account_zone(data, &mut tx, account.unwrap(), client), - "cryp_spawn" => Rpc::cryp_spawn(data, &mut tx, account.unwrap(), client), + "construct_spawn" => Rpc::construct_spawn(data, &mut tx, account.unwrap(), client), "game_state" => Rpc::game_state(data, &mut tx, account.unwrap(), client), "game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client), @@ -86,7 +86,7 @@ impl Rpc { "instance_new" => Rpc::instance_new(data, &mut tx, account.unwrap(), client), "instance_state" => Rpc::instance_state(data, &mut tx, account.unwrap(), client), - "player_mm_cryps_set" => Rpc::player_mm_cryps_set(data, &mut tx, account.unwrap(), client), + "player_mm_constructs_set" => Rpc::player_mm_constructs_set(data, &mut tx, account.unwrap(), client), "player_vbox_accept" => Rpc::player_vbox_accept(data, &mut tx, account.unwrap(), client), "player_vbox_apply" => Rpc::player_vbox_apply(data, &mut tx, account.unwrap(), client), "player_vbox_combine" => Rpc::player_vbox_combine(data, &mut tx, account.unwrap(), client), @@ -165,20 +165,20 @@ impl Rpc { } - fn cryp_spawn(data: Vec, tx: &mut Transaction, account: Account, client: &mut WebSocket) -> Result { - let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; + fn construct_spawn(data: Vec, tx: &mut Transaction, account: Account, client: &mut WebSocket) -> Result { + let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; Rpc::send_msg(client, RpcResponse { - method: "cryp_spawn".to_string(), - params: RpcResult::CrypSpawn(cryp_spawn(msg.params, tx, &account)?) + method: "construct_spawn".to_string(), + params: RpcResult::ConstructSpawn(construct_spawn(msg.params, tx, &account)?) })?; - let cryp_list = RpcResponse { - method: "account_cryps".to_string(), - params: RpcResult::CrypList(account_cryps(tx, &account)?) + let construct_list = RpcResponse { + method: "account_constructs".to_string(), + params: RpcResult::ConstructList(account_constructs(tx, &account)?) }; - Ok(cryp_list) + Ok(construct_list) } fn account_create(data: Vec, tx: &mut Transaction, _client: &mut WebSocket) -> Result { @@ -210,13 +210,13 @@ impl Rpc { // let account = account_create(AccountCreateParams { name: acc_name, password: "grepgrepgrep".to_string() }, tx)?; // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); - // cryp_spawn(CrypSpawnParams { name }, tx, &account)?; + // construct_spawn(ConstructSpawnParams { name }, tx, &account)?; // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); - // cryp_spawn(CrypSpawnParams { name }, tx, &account)?; + // construct_spawn(ConstructSpawnParams { name }, tx, &account)?; // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); - // cryp_spawn(CrypSpawnParams { name }, tx, &account)?; + // construct_spawn(ConstructSpawnParams { name }, tx, &account)?; // let res = RpcResponse { // method: "account_create".to_string(), @@ -227,10 +227,10 @@ impl Rpc { // } - fn account_cryps(_data: Vec, tx: &mut Transaction, account: Account, _client: &mut WebSocket) -> Result { + fn account_constructs(_data: Vec, tx: &mut Transaction, account: Account, _client: &mut WebSocket) -> Result { Ok(RpcResponse { - method: "account_cryps".to_string(), - params: RpcResult::CrypList(account_cryps(tx, &account)?) + method: "account_constructs".to_string(), + params: RpcResult::ConstructList(account_constructs(tx, &account)?) }) } @@ -300,12 +300,12 @@ impl Rpc { } } - fn player_mm_cryps_set(data: Vec, tx: &mut Transaction, account: Account, _client: &mut WebSocket) -> Result { - let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; + fn player_mm_constructs_set(data: Vec, tx: &mut Transaction, account: Account, _client: &mut WebSocket) -> Result { + let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; let response = RpcResponse { method: "instance_state".to_string(), - params: RpcResult::InstanceState(player_mm_cryps_set(msg.params, tx, &account)?) + params: RpcResult::InstanceState(player_mm_constructs_set(msg.params, tx, &account)?) }; return Ok(response); @@ -354,8 +354,8 @@ impl Rpc { }; Rpc::send_msg(client, RpcResponse { - method: "account_cryps".to_string(), - params: RpcResult::CrypList(account_cryps(tx, &account)?) + method: "account_constructs".to_string(), + params: RpcResult::ConstructList(account_constructs(tx, &account)?) })?; return Ok(response); @@ -381,8 +381,8 @@ impl Rpc { }; Rpc::send_msg(client, RpcResponse { - method: "account_cryps".to_string(), - params: RpcResult::CrypList(account_cryps(tx, &account)?) + method: "account_constructs".to_string(), + params: RpcResult::ConstructList(account_constructs(tx, &account)?) })?; return Ok(response); @@ -397,12 +397,12 @@ pub struct RpcResponse { #[derive(Debug,Clone,Serialize,Deserialize)] pub enum RpcResult { - CrypSpawn(Cryp), - CrypForget(Cryp), - CrypLearn(Cryp), - CrypUnspec(Cryp), + ConstructSpawn(Construct), + ConstructForget(Construct), + ConstructLearn(Construct), + ConstructUnspec(Construct), Account(Account), - CrypList(Vec), + ConstructList(Vec), GameState(Game), ItemInfo(ItemInfoCtr), InstanceScores(Vec<(String, Score)>), @@ -422,50 +422,50 @@ pub struct RpcMessage { } #[derive(Debug,Clone,Serialize,Deserialize)] -struct CrypSpawnMsg { +struct ConstructSpawnMsg { method: String, - params: CrypSpawnParams, + params: ConstructSpawnParams, } #[derive(Debug,Clone,Serialize,Deserialize)] -pub struct CrypSpawnParams { +pub struct ConstructSpawnParams { pub name: String, } #[derive(Debug,Clone,Serialize,Deserialize)] -struct CrypLearnMsg { +struct ConstructLearnMsg { method: String, - params: CrypLearnParams, + params: ConstructLearnParams, } #[derive(Debug,Clone,Serialize,Deserialize)] -pub struct CrypLearnParams { +pub struct ConstructLearnParams { pub id: Uuid, pub skill: Skill, } #[derive(Debug,Clone,Serialize,Deserialize)] -pub struct CrypForgetParams { +pub struct ConstructForgetParams { pub id: Uuid, pub skill: Skill, } #[derive(Debug,Clone,Serialize,Deserialize)] -struct CrypForgetMsg { +struct ConstructForgetMsg { method: String, - params: CrypForgetParams, + params: ConstructForgetParams, } #[derive(Debug,Clone,Serialize,Deserialize)] -pub struct CrypUnspecParams { +pub struct ConstructUnspecParams { pub id: Uuid, pub spec: Spec, } #[derive(Debug,Clone,Serialize,Deserialize)] -struct CrypUnspecMsg { +struct ConstructUnspecMsg { method: String, - params: CrypUnspecParams, + params: ConstructUnspecParams, } #[derive(Debug,Clone,Serialize,Deserialize)] @@ -487,7 +487,7 @@ pub struct GameStateParams { // #[derive(Debug,Clone,Serialize,Deserialize)] // pub struct GamePveParams { -// pub cryp_ids: Vec, +// pub construct_ids: Vec, // } #[derive(Debug,Clone,Serialize,Deserialize)] @@ -499,8 +499,8 @@ struct GameSkillMsg { #[derive(Debug,Clone,Serialize,Deserialize)] pub struct GameSkillParams { pub game_id: Uuid, - pub cryp_id: Uuid, - pub target_cryp_id: Option, + pub construct_id: Uuid, + pub target_construct_id: Option, pub skill: Skill, } @@ -529,7 +529,7 @@ pub struct AccountLoginParams { } #[derive(Debug,Clone,Serialize,Deserialize)] -struct AccountCrypsMsg { +struct AccountConstructsMsg { method: String, params: (), } @@ -542,7 +542,7 @@ struct InstanceLobbyMsg { #[derive(Debug,Clone,Serialize,Deserialize)] pub struct InstanceLobbyParams { - pub cryp_ids: Vec, + pub construct_ids: Vec, pub name: String, pub players: usize, pub password: Option, @@ -557,7 +557,7 @@ struct InstanceJoinMsg { #[derive(Debug,Clone,Serialize,Deserialize)] pub struct InstanceJoinParams { pub instance_id: Uuid, - pub cryp_ids: Vec, + pub construct_ids: Vec, } #[derive(Debug,Clone,Serialize,Deserialize)] @@ -583,14 +583,14 @@ pub struct InstanceStateParams { } #[derive(Debug,Clone,Serialize,Deserialize)] -struct PlayerCrypsSetMsg { +struct PlayerConstructsSetMsg { method: String, - params: PlayerCrypsSetParams, + params: PlayerConstructsSetParams, } #[derive(Debug,Clone,Serialize,Deserialize)] -pub struct PlayerCrypsSetParams { - pub cryp_ids: Vec, +pub struct PlayerConstructsSetParams { + pub construct_ids: Vec, } #[derive(Debug,Clone,Serialize,Deserialize)] @@ -638,7 +638,7 @@ struct VboxApplyMsg { #[derive(Debug,Clone,Serialize,Deserialize)] pub struct VboxApplyParams { pub instance_id: Uuid, - pub cryp_id: Uuid, + pub construct_id: Uuid, pub index: usize, } @@ -651,7 +651,7 @@ struct VboxUnequipMsg { #[derive(Debug,Clone,Serialize,Deserialize)] pub struct VboxUnequipParams { pub instance_id: Uuid, - pub cryp_id: Uuid, + pub construct_id: Uuid, pub target: Item, } @@ -674,7 +674,7 @@ pub struct VboxReclaimParams { // #[test] // fn rpc_parse() { // let rpc = Rpc {}; -// let msg = GenerateMsg { method: "cryp_generate".to_string(), params: GenerateParams { level: 64 } }; +// let msg = GenerateMsg { method: "construct_generate".to_string(), params: GenerateParams { level: 64 } }; // let v = to_vec(&msg).unwrap(); // let received = rpc.receive(Message::Binary(v)); // } diff --git a/server/src/skill.rs b/server/src/skill.rs index 6d917f89..d4cf3c02 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -2,7 +2,7 @@ use rand::{thread_rng, Rng}; use uuid::Uuid; use util::{IntPct}; -use cryp::{Cryp, CrypEffect, EffectMeta, Stat}; +use construct::{Construct, ConstructEffect, EffectMeta, Stat}; use item::{Item}; use game::{Game}; @@ -17,19 +17,19 @@ pub fn resolution_steps(cast: &Cast, game: &mut Game) -> Resolutions { pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) -> Resolutions { let skill = cast.skill; - let source = game.cryp_by_id(cast.source_cryp_id).unwrap().clone(); - let targets = game.get_targets(cast.skill, &source, cast.target_cryp_id); + let source = game.construct_by_id(cast.source_construct_id).unwrap().clone(); + let targets = game.get_targets(cast.skill, &source, cast.target_construct_id); if skill.aoe() { // Send an aoe skill event for anims - resolutions.push(Resolution::new(&source, &game.cryp_by_id(cast.target_cryp_id).unwrap().clone()).event(Event::AoeSkill { skill })); + resolutions.push(Resolution::new(&source, &game.construct_by_id(cast.target_construct_id).unwrap().clone()).event(Event::AoeSkill { skill })); } for target_id in targets { // we clone the current state of the target and source // so we can modify them during the resolution // no more than 1 mutable ref allowed on game - let mut source = game.cryp_by_id(cast.source_cryp_id).unwrap().clone(); - let mut target = game.cryp_by_id(target_id).unwrap().clone(); + let mut source = game.construct_by_id(cast.source_construct_id).unwrap().clone(); + let mut target = game.construct_by_id(target_id).unwrap().clone(); // bail out on ticks that have been removed if skill.is_tick() && target.effects.iter().find(|ce| match ce.tick { @@ -42,8 +42,8 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) - resolutions = resolve(cast.skill, &mut source, &mut target, resolutions); // save the changes to the game - game.update_cryp(&mut source); - game.update_cryp(&mut target); + game.update_construct(&mut source); + game.update_construct(&mut target); // do additional steps resolutions = post_resolve(cast.skill, game, resolutions); @@ -52,7 +52,7 @@ pub fn pre_resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) - return resolutions; } -pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutions: Vec) -> Resolutions { +pub fn resolve(skill: Skill, source: &mut Construct, target: &mut Construct, mut resolutions: Vec) -> Resolutions { if let Some(disable) = source.disabled(skill) { resolutions.push(Resolution::new(source, target).event(Event::Disable { disable, skill })); return resolutions; @@ -179,8 +179,8 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> Resolutions { for Resolution { source, target, event } in resolutions.clone() { - let mut source = game.cryp_by_id(source.id).unwrap().clone(); - let mut target = game.cryp_by_id(target.id).unwrap().clone(); + let mut source = game.construct_by_id(source.id).unwrap().clone(); + let mut target = game.construct_by_id(target.id).unwrap().clone(); match event { Event::Damage { amount, skill, mitigation: _, colour: _ } => { @@ -208,8 +208,8 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> _ => (), }; - game.update_cryp(&mut source); - game.update_cryp(&mut target); + game.update_construct(&mut source); + game.update_construct(&mut target); }; return resolutions; @@ -221,30 +221,30 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> pub struct Cast { pub id: Uuid, pub source_player_id: Uuid, - pub source_cryp_id: Uuid, - pub target_cryp_id: Uuid, + pub source_construct_id: Uuid, + pub target_construct_id: Uuid, pub skill: Skill, pub speed: u64, } impl Cast { - pub fn new(source_cryp_id: Uuid, source_player_id: Uuid, target_cryp_id: Uuid, skill: Skill) -> Cast { + pub fn new(source_construct_id: Uuid, source_player_id: Uuid, target_construct_id: Uuid, skill: Skill) -> Cast { return Cast { id: Uuid::new_v4(), - source_cryp_id, + source_construct_id, source_player_id, - target_cryp_id, + target_construct_id, skill, speed: 0, }; } - pub fn new_tick(source: &mut Cryp, target: &mut Cryp, skill: Skill) -> Cast { + pub fn new_tick(source: &mut Construct, target: &mut Construct, skill: Skill) -> Cast { Cast { id: Uuid::new_v4(), - source_cryp_id: source.id, + source_construct_id: source.id, source_player_id: source.account, - target_cryp_id: target.id, + target_construct_id: target.id, skill, speed: 0, } @@ -259,23 +259,23 @@ pub type Disable = Vec; pub type Immunity = Vec; #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] -pub struct LogCryp { +pub struct LogConstruct { pub id: Uuid, pub name: String, } #[derive(Debug,Clone,PartialEq,Serialize,Deserialize)] pub struct Resolution { - pub source: LogCryp, - pub target: LogCryp, + pub source: LogConstruct, + pub target: LogConstruct, pub event: Event, } impl Resolution { - fn new(source: &Cryp, target: &Cryp) -> Resolution { + fn new(source: &Construct, target: &Construct) -> Resolution { Resolution { - source: LogCryp { id: source.id, name: source.name.clone() }, - target: LogCryp { id: target.id, name: target.name.clone() }, + source: LogConstruct { id: source.id, name: source.name.clone() }, + target: LogConstruct { id: target.id, name: target.name.clone() }, event: Event::Incomplete, } } @@ -641,49 +641,49 @@ impl Skill { } } - pub fn effect(&self) -> Vec { + pub fn effect(&self) -> Vec { match self { // Modifiers - Skill::Amplify => vec![CrypEffect {effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], - Skill::Banish => vec![CrypEffect {effect: Effect::Banish, duration: 1, meta: None, tick: None}], - Skill::Block => vec![CrypEffect {effect: Effect::Block, duration: 1, meta: Some(EffectMeta::Multiplier(50)), tick: None}], - Skill::Buff => vec![CrypEffect {effect: Effect::Buff, duration: 2, meta: Some(EffectMeta::Multiplier(125)), tick: None }], - - Skill::Corrupt => vec![CrypEffect {effect: Effect::Corrupt, duration: 2, meta: None, tick: None}, - CrypEffect {effect: Effect::Corruption, duration: 3, meta: None, tick: None}], - - Skill::Clutch => vec![CrypEffect {effect: Effect::Clutch, duration: 1, meta: None, tick: None }], - Skill::Curse => vec![CrypEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], - Skill::Debuff => vec![CrypEffect {effect: Effect::Slow, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }], - Skill::Decay => vec![CrypEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }, - CrypEffect {effect: Effect::Decay, duration: 3, meta: None, tick: None }], - Skill::Haste => vec![CrypEffect {effect: Effect::Haste, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None }], - Skill::Hex => vec![CrypEffect {effect: Effect::Hex, duration: 2, meta: None, tick: None}], - Skill::Hostility => vec![CrypEffect {effect: Effect::Hostility, duration: 2, meta: None, tick: None}, - CrypEffect {effect: Effect::Hatred, duration: 5, meta: None, tick: None}], - Skill::Impurity => vec![CrypEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }], - Skill::Invert => vec![CrypEffect {effect: Effect::Invert, duration: 2, meta: None, tick: None}], + Skill::Amplify => vec![ConstructEffect {effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], + Skill::Banish => vec![ConstructEffect {effect: Effect::Banish, duration: 1, meta: None, tick: None}], + Skill::Block => vec![ConstructEffect {effect: Effect::Block, duration: 1, meta: Some(EffectMeta::Multiplier(50)), tick: None}], + Skill::Buff => vec![ConstructEffect {effect: Effect::Buff, duration: 2, meta: Some(EffectMeta::Multiplier(125)), tick: None }], - Skill::Parry => vec![CrypEffect {effect: Effect::Parry, duration: 2, meta: None, tick: None }], - Skill::Reflect => vec![CrypEffect {effect: Effect::Reflect, duration: 1, meta: None, tick: None }], - Skill::Throw => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}, - CrypEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}], + Skill::Corrupt => vec![ConstructEffect {effect: Effect::Corrupt, duration: 2, meta: None, tick: None}, + ConstructEffect {effect: Effect::Corruption, duration: 3, meta: None, tick: None}], - Skill::Ruin => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}], + Skill::Clutch => vec![ConstructEffect {effect: Effect::Clutch, duration: 1, meta: None, tick: None }], + Skill::Curse => vec![ConstructEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], + Skill::Debuff => vec![ConstructEffect {effect: Effect::Slow, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }], + Skill::Decay => vec![ConstructEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }, + ConstructEffect {effect: Effect::Decay, duration: 3, meta: None, tick: None }], + Skill::Haste => vec![ConstructEffect {effect: Effect::Haste, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None }], + Skill::Hex => vec![ConstructEffect {effect: Effect::Hex, duration: 2, meta: None, tick: None}], + Skill::Hostility => vec![ConstructEffect {effect: Effect::Hostility, duration: 2, meta: None, tick: None}, + ConstructEffect {effect: Effect::Hatred, duration: 5, meta: None, tick: None}], + Skill::Impurity => vec![ConstructEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }], + Skill::Invert => vec![ConstructEffect {effect: Effect::Invert, duration: 2, meta: None, tick: None}], + + Skill::Parry => vec![ConstructEffect {effect: Effect::Parry, duration: 2, meta: None, tick: None }], + Skill::Reflect => vec![ConstructEffect {effect: Effect::Reflect, duration: 1, meta: None, tick: None }], + Skill::Throw => vec![ConstructEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}, + ConstructEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}], + + Skill::Ruin => vec![ConstructEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}], - Skill::Scatter => vec![CrypEffect {effect: Effect::Scatter, duration: 2, meta: None, tick: None}], - Skill::Silence => vec![CrypEffect {effect: Effect::Silence, duration: 2, meta: None, tick: None}], - Skill::Siphon => vec![CrypEffect {effect: Effect::Siphon, duration: 2, meta: None, tick: None}], - Skill::Sleep => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], - Skill::Snare => vec![CrypEffect {effect: Effect::Snare, duration: 2, meta: None, tick: None}], - Skill::Strangle => vec![CrypEffect {effect: Effect::Strangle, duration: 2, meta: None, tick: None}], - Skill::Stun => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], - Skill::Taunt => vec![CrypEffect {effect: Effect::Taunt, duration: 2, meta: None, tick: None}], - Skill::Triage => vec![CrypEffect {effect: Effect::Triage, duration: 2, meta: None, tick: None}], + Skill::Scatter => vec![ConstructEffect {effect: Effect::Scatter, duration: 2, meta: None, tick: None}], + Skill::Silence => vec![ConstructEffect {effect: Effect::Silence, duration: 2, meta: None, tick: None}], + Skill::Siphon => vec![ConstructEffect {effect: Effect::Siphon, duration: 2, meta: None, tick: None}], + Skill::Sleep => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], + Skill::Snare => vec![ConstructEffect {effect: Effect::Snare, duration: 2, meta: None, tick: None}], + Skill::Strangle => vec![ConstructEffect {effect: Effect::Strangle, duration: 2, meta: None, tick: None}], + Skill::Stun => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], + Skill::Taunt => vec![ConstructEffect {effect: Effect::Taunt, duration: 2, meta: None, tick: None}], + Skill::Triage => vec![ConstructEffect {effect: Effect::Triage, duration: 2, meta: None, tick: None}], //Unused - Skill::Injure => vec![CrypEffect {effect: Effect::Injured, duration: 2, meta: None, tick: None }], + Skill::Injure => vec![ConstructEffect {effect: Effect::Injured, duration: 2, meta: None, tick: None }], _ => { panic!("{:?} no skill effect", self); @@ -876,7 +876,7 @@ impl Skill { } } -fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn touch(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { target.deal_red_damage(skill, 0) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -884,7 +884,7 @@ fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn attack(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() @@ -893,7 +893,7 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn strike(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() @@ -902,7 +902,7 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn injure(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() @@ -910,21 +910,21 @@ fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); - + return results; } -fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn stun(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); - + return results; } -fn sleep(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn sleep(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); - + let amount = source.green_damage().pct(skill.multiplier()); target.deal_green_damage(skill, amount) .into_iter() @@ -933,13 +933,13 @@ fn sleep(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn clutch(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results; } -fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn taunt(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let red_amount = source.red_damage().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); @@ -948,27 +948,27 @@ fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn throw(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results; } -fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn strangle(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter().for_each(|e| { - let CrypEffect { effect: _, duration, meta: _, tick: _ } = e; + let ConstructEffect { effect: _, duration, meta: _, tick: _ } = e; let strangle = e.clone().set_tick(Cast::new_tick(source, target, Skill::StrangleTick)); results.push(Resolution::new(source, target).event(target.add_effect(skill, strangle))); - let attacker_strangle = CrypEffect::new(Effect::Strangling, duration); + let attacker_strangle = ConstructEffect::new(Effect::Strangling, duration); results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_strangle))); }); return strangle_tick(source, target, results, Skill::StrangleTick); } -fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn strangle_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() @@ -979,7 +979,7 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, let i = source.effects .iter() .position(|e| e.effect == Effect::Strangling) - .expect("no strangling on cryp"); + .expect("no strangling on construct"); source.effects.remove(i); results.push(Resolution::new(source, source).event(Event::Removal { effect: Effect::Strangling })); } @@ -987,19 +987,19 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, return results; } -fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn block(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results; } -fn buff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn buff(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results; } -fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn parry(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let red_amount = source.red_damage().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); @@ -1008,7 +1008,7 @@ fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn riposte(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() @@ -1017,7 +1017,7 @@ fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill return results; } -fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn snare(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); @@ -1037,7 +1037,7 @@ fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn slay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn slay(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.red_damage().pct(skill.multiplier()); let slay_events = target.deal_red_damage(skill, amount); @@ -1057,7 +1057,7 @@ fn slay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: S return results; } -fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn heal(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.green_damage().pct(skill.multiplier()); target.deal_green_damage(skill, amount) .into_iter() @@ -1065,7 +1065,7 @@ fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: S return results; } -fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn triage(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter().for_each(|e| { let triage = e.clone().set_tick(Cast::new_tick(source, target, Skill::TriageTick)); results.push(Resolution::new(source, target).event(target.add_effect(skill, triage))); @@ -1074,7 +1074,7 @@ fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return triage_tick(source, target, results, Skill::TriageTick); } -fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn triage_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.green_damage().pct(skill.multiplier()); target.deal_green_damage(Skill::TriageTick, amount) .into_iter() @@ -1082,7 +1082,7 @@ fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s return results; } -fn chaos(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn chaos(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let mut rng = thread_rng(); let b_rng: u64 = rng.gen_range(0, 30); let amount = source.blue_damage().pct(skill.multiplier() + b_rng); @@ -1097,7 +1097,7 @@ fn chaos(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn blast(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.blue_damage().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() @@ -1105,28 +1105,28 @@ fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn amplify(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn haste(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn debuff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn debuff(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - +fn decay(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + skill.effect().into_iter().for_each(|e| { - let CrypEffect { effect, duration: _, meta: _, tick: _ } = e; + let ConstructEffect { effect, duration: _, meta: _, tick: _ } = e; let apply_effect = match effect { Effect::Wither => e.clone(), Effect::Decay => e.clone().set_tick(Cast::new_tick(source, target, Skill::DecayTick)), @@ -1138,7 +1138,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return decay_tick(source, target, results, Skill::DecayTick); } -fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn decay_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.blue_damage().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() @@ -1148,13 +1148,13 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, sk // corrupt is the buff effect // when attacked it runs corruption and applies a debuff -fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn corrupt(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let corrupt = skill.effect().first().unwrap().clone(); results.push(Resolution::new(source, target).event(target.add_effect(skill, corrupt))); return results;; } -fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn corruption(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let corruption = skill.effect().last().unwrap().clone() .set_tick(Cast::new_tick(source, target, Skill::CorruptionTick)); @@ -1162,7 +1162,7 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, sk return corruption_tick(source, target, results, Skill::CorruptionTick); } -fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn corruption_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.blue_damage().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() @@ -1170,26 +1170,26 @@ fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolution return results; } -fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn ruin(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn hex(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn hostility(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let hostility = skill.effect().first().unwrap().clone(); results.push(Resolution::new(source, target).event(target.add_effect(skill, hostility))); return results;; } -fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, reflect_skill: Skill, amount: u64, skill: Skill) -> Resolutions { +fn hatred(source: &mut Construct, target: &mut Construct, mut results: Resolutions, reflect_skill: Skill, amount: u64, skill: Skill) -> Resolutions { let hatred = skill.effect().last().unwrap().clone() .set_meta(EffectMeta::AddedDamage(amount)); @@ -1197,25 +1197,25 @@ fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, reflec return results;; } -fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn curse(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn impurity(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn impurity(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn invert(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results;; } -fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn reflect(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); @@ -1225,7 +1225,7 @@ fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill return results;; } -fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn recharge(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let red_amount = source.red_damage().pct(skill.multiplier()); let blue_amount = source.blue_damage().pct(skill.multiplier()); @@ -1233,7 +1233,7 @@ fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skil return results; } -fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn siphon(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter().for_each(|e| { let siphon = e.clone().set_tick(Cast::new_tick(source, target, Skill::SiphonTick)); results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon))); @@ -1242,7 +1242,7 @@ fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return siphon_tick(source, target, results, Skill::SiphonTick); } -fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn siphon_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.blue_damage().pct(skill.multiplier()); let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount); @@ -1262,7 +1262,7 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s return results; } -fn scatter(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn scatter(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { let blue_amount = source.blue_damage().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount))); @@ -1274,13 +1274,13 @@ fn scatter(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill return results; } -fn scatter_hit(source: &Cryp, target: &Cryp, mut results: Resolutions, game: &mut Game, event: Event) -> Resolutions { +fn scatter_hit(source: &Construct, target: &Construct, mut results: Resolutions, game: &mut Game, event: Event) -> Resolutions { match event { Event::Damage { amount, skill, mitigation: _, colour } => { let scatter = target.effects.iter().find(|e| e.effect == Effect::Scatter).unwrap(); if let Some(EffectMeta::ScatterTarget(scatter_target_id)) = scatter.meta { - let mut scatter_target = game.cryp_by_id(scatter_target_id).unwrap(); + let mut scatter_target = game.construct_by_id(scatter_target_id).unwrap(); let res = match colour { Colour::Red => scatter_target.deal_red_damage(skill, amount), @@ -1300,7 +1300,7 @@ fn scatter_hit(source: &Cryp, target: &Cryp, mut results: Resolutions, game: &mu } } -fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn silence(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); @@ -1319,7 +1319,7 @@ fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill return results; } -fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, _skill: Skill) -> Resolutions { +fn purge(source: &mut Construct, target: &mut Construct, mut results: Resolutions, _skill: Skill) -> Resolutions { while let Some(i) = target.effects .iter() .position(|ce| ce.effect.category() == EffectCategory::Buff) { @@ -1330,7 +1330,7 @@ fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, _skill: return results; } -fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn purify(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { results.push(Resolution::new(source, target).event(Event::Skill { skill })); let amount = source.green_damage().pct(skill.multiplier()); while let Some(i) = target.effects @@ -1346,7 +1346,7 @@ fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: return results; } -fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { +fn banish(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { skill.effect().into_iter() .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); return results; @@ -1358,11 +1358,11 @@ mod tests { #[test] fn heal_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()) .learn(Skill::Heal); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()) .learn(Skill::Heal); @@ -1373,10 +1373,10 @@ mod tests { #[test] fn decay_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()); decay(&mut x, &mut y, vec![], Skill::Decay); @@ -1390,10 +1390,10 @@ mod tests { #[test] fn block_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()); // ensure it doesn't have 0 pd @@ -1414,10 +1414,10 @@ mod tests { #[test] fn clutch_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()); x.red_damage.force(10000000000000); // multiplication of int max will cause overflow @@ -1444,10 +1444,10 @@ mod tests { #[test] fn injure_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()); resolve(Skill::Injure, &mut x, &mut y, vec![]); @@ -1457,10 +1457,10 @@ mod tests { #[test] fn invert_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()); // give red shield but reduce to 0 @@ -1496,10 +1496,10 @@ mod tests { #[test] fn reflect_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()); reflect(&mut y.clone(), &mut y, vec![], Skill::Reflect); @@ -1525,10 +1525,10 @@ mod tests { #[test] fn siphon_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()); x.green_life.reduce(512); @@ -1562,10 +1562,10 @@ mod tests { #[test] fn triage_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"pretaliation".to_string()); // ensure it doesn't have 0 sd @@ -1586,10 +1586,10 @@ mod tests { #[test] fn recharge_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"pretaliation".to_string()); y.red_life.force(50); @@ -1613,7 +1613,7 @@ mod tests { #[test] fn silence_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); silence(&mut x.clone(), &mut x, vec![], Skill::Silence); @@ -1623,7 +1623,7 @@ mod tests { #[test] fn amplify_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); x.blue_damage.force(50); @@ -1635,7 +1635,7 @@ mod tests { #[test] fn purify_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()); decay(&mut x.clone(), &mut x, vec![], Skill::Decay); diff --git a/server/src/spec.rs b/server/src/spec.rs index d1406908..c642dc1e 100644 --- a/server/src/spec.rs +++ b/server/src/spec.rs @@ -1,4 +1,4 @@ -use cryp::{Stat, Colours}; +use construct::{Stat, Colours}; use util::{IntPct}; #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] @@ -59,8 +59,8 @@ impl Spec { } } - pub fn apply(&self, modified: u64, base: u64, cryp_colours: &Colours, player_colours: &Colours) -> u64 { - let cryp_colour_total: u64 = (cryp_colours.red + cryp_colours.green + cryp_colours.blue) as u64; + pub fn apply(&self, modified: u64, base: u64, construct_colours: &Colours, player_colours: &Colours) -> u64 { + let construct_colour_total: u64 = (construct_colours.red + construct_colours.green + construct_colours.blue) as u64; match *self { // Upgrades to Damage Spec Spec::Damage => modified + base.pct(5), @@ -157,42 +157,42 @@ impl Spec { if player_colours.green >= 5 { mult += 15 }; if player_colours.green >= 10 { mult += 30 }; if player_colours.green >= 20 { mult += 45 }; - mult * cryp_colour_total + mult * construct_colour_total }, Spec::RedLifeI => modified + { let mut mult: u64 = 25; if player_colours.red >= 5 { mult += 15 }; if player_colours.red >= 10 { mult += 30 }; if player_colours.red >= 20 { mult += 45 }; - mult * cryp_colour_total + mult * construct_colour_total }, Spec::BlueLifeI => modified + { let mut mult: u64 = 25; if player_colours.blue >= 5 { mult += 15 }; if player_colours.blue >= 10 { mult += 30 }; if player_colours.blue >= 20 { mult += 45 }; - mult * cryp_colour_total + mult * construct_colour_total }, Spec::GRLI => modified + { let mut mult: u64 = 15; if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 }; if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 }; - mult * cryp_colour_total + mult * construct_colour_total }, Spec::GBLI => modified + { let mut mult: u64 = 15; if player_colours.green >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.green >= 5 && player_colours.red >= 5 { mult += 20 }; if player_colours.green >= 10 && player_colours.red >= 10 { mult += 40 }; - mult * cryp_colour_total + mult * construct_colour_total }, Spec::RBLI => modified + { let mut mult: u64 = 15; if player_colours.blue >= 2 && player_colours.red >= 2 { mult += 10 }; if player_colours.blue >= 5 && player_colours.red >= 5 { mult += 20 }; if player_colours.blue >= 10 && player_colours.red >= 10 { mult += 40 }; - mult * cryp_colour_total + mult * construct_colour_total }, } } diff --git a/server/src/vbox.rs b/server/src/vbox.rs index b3e61de6..f551859a 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -13,7 +13,7 @@ use failure::err_msg; use account::Account; use rpc::{VboxAcceptParams, VboxDiscardParams, VboxCombineParams, VboxApplyParams, VboxReclaimParams, VboxUnequipParams}; use instance::{Instance, instance_get, instance_update}; -use cryp::{Colours}; +use construct::{Colours}; use item::*; @@ -181,13 +181,13 @@ pub fn vbox_reclaim(params: VboxReclaimParams, tx: &mut Transaction, account: &A pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Account) -> Result { let instance = instance_get(tx, params.instance_id)? - .vbox_apply(account.id, params.index, params.cryp_id)?; + .vbox_apply(account.id, params.index, params.construct_id)?; return instance_update(tx, instance); } pub fn vbox_unequip(params: VboxUnequipParams, tx: &mut Transaction, account: &Account) -> Result { let instance = instance_get(tx, params.instance_id)? - .vbox_unequip(account.id, params.target, params.cryp_id)?; + .vbox_unequip(account.id, params.target, params.construct_id)?; return instance_update(tx, instance); } diff --git a/server/src/zone.rs b/server/src/zone.rs index 4851b49c..f824587f 100644 --- a/server/src/zone.rs +++ b/server/src/zone.rs @@ -101,7 +101,7 @@ pub fn zone_get(tx: &mut Transaction, id: Uuid) -> Result { None => return Err(err_msg("zone not found")), }; - // tells from_slice to cast into a cryp + // tells from_slice to cast into a construct let bytes: Vec = returned.get("data"); let zone = match from_slice::(&bytes) { Ok(z) => z, @@ -180,7 +180,7 @@ pub fn zone_join(params: ZoneJoinParams, tx: &mut Transaction, account: &Account "BOSS" => GameMode::Zone3v3HealerBoss, _ => return Err(err_msg("unknown zone tag")), }; - game = game_pve_new(params.cryp_ids, mode, tx, account)?; + game = game_pve_new(params.construct_ids, mode, tx, account)?; game.set_zone(zone.id, params.node_id); encounter.game_id = Some(game.id);