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 db7391a4..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,40 +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 { - font-size: 12pt; - } - - .game-cryp figure { + .game-construct figure { padding: 0 0.25em; } @@ -127,7 +123,7 @@ } */} -.game-cryp .skills { +.game-construct .skills { grid-area: skills; display: flex; flex-flow: column-reverse; @@ -135,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; @@ -157,7 +153,7 @@ margin-right: 0.5em; } -.game-cryp button { +.game-construct button { color: #888; flex: 1 1 100%; padding: 0; @@ -165,36 +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; - font-size: 14pt; 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%); } @@ -207,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;*/ @@ -237,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; @@ -257,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; @@ -277,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 54e1e149..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) { @@ -22,6 +22,10 @@ .instance .info table td svg { height: 50%; } + + .instance svg { + height: 1.5em; + } } .instance .top { @@ -29,7 +33,7 @@ } .instance .scoreboard { - grid-area: cryps; + grid-area: constructs; } .instance-ui-btn { @@ -56,8 +60,8 @@ margin-top: 1.5em; } -.instance .cryps { - grid-area: cryps; +.instance .constructs { + grid-area: constructs; } .instance .equip { @@ -144,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: @@ -173,17 +177,17 @@ transition-timing-function: ease; */} -.instance-cryp: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; @@ -192,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; } @@ -232,7 +236,7 @@ } } */ -.cryp-list .specs { +.construct-list .specs { margin-top: 1em; grid-area: specs; display: flex; @@ -241,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; @@ -263,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; @@ -285,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 0a747e94..333a7fbe 100644 --- a/client/assets/styles/instance.mobile.css +++ b/client/assets/styles/instance.mobile.css @@ -1,20 +1,20 @@ @media (max-height: 800px), (max-width: 1000px) { .instance { display: grid; - grid-template-columns: 100%; - grid-template-rows: repeat(4, min-content); + grid-template-columns: 1fr; + grid-template-rows: min-content, min-content, min-content, 1fr; grid-template-areas: "top" "controls" - "first" - "second" + "vbox" + "constructs" } /* Default view */ .instance .equip { display: none; } .instance .info { display: none; } - .instance .cryp-list { display: none; } + .instance .construct-list { display: none; } .vbox { - grid-area: first; + grid-area: vbox; display: grid; grid-template-rows: min-content min-content min-content; grid-template-columns: 1fr; @@ -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{ @@ -47,22 +47,21 @@ #toggle-vbox:checked ~ .vbox { display: none; } #toggle-vbox:checked ~ .equip { display: initial; - grid-area: first; + grid-area: vbox; } #toggle-vbox:checked ~ .highlight { display: initial; } - #toggle-vbox:checked ~ .cryp-list { - grid-area: second; - display: flex; + #toggle-vbox:checked ~ .construct-list { + grid-area: constructs; + display: grid; justify-content: center; - flex-flow: row wrap; - flex: 1; - width: 100%; - } + grid-template-columns: 1fr 1fr; + grid-template-rows: 1fr 1fr; + } #toggle-vbox { display: none; } @@ -76,15 +75,15 @@ margin-right: 0.5em; } - .cryp-list .skills { + .construct-list .skills { flex-flow: row; align-items: stretch; } - .instance-cryp { - flex: 1; + .instance-construct { + grid-row: 2; display: grid; - grid-template-rows: min-content min-content; + grid-template-rows: min-content 1fr; grid-template-areas: "name " "avatar "; @@ -95,28 +94,25 @@ transition-delay: 0; transition-timing-function: ease; } - .instance-cryp img { - width: 35px; - } - .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 { - flex: 1; - order: -1; + .instance-construct-active { + grid-row: 1; + grid-column: 1 / 3; display: grid; - grid-template-rows: min-content min-content min-content min-content min-content; + grid-template-rows: min-content min-content min-content 1fr min-content; grid-template-areas: "name " "skills " @@ -133,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..9bb63d57 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; @@ -170,6 +170,11 @@ button.left:hover, button.left:focus { box-shadow: inset 0.5em 0 0 0 whitesmoke; } +a { + color: whitesmoke; + font-size: 150%; +} + svg { fill: none; stroke: whitesmoke; @@ -277,13 +282,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 +354,7 @@ header { MENU */ -.menu-cryps { +.menu-constructs { display: grid; grid-template-rows: min-content min-content; @@ -358,14 +363,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 +379,7 @@ header { justify-content: center; } -.spawn-btn .menu-cryp { +.spawn-btn .menu-construct { border: 1px solid #333; color: #333; display: flex; @@ -399,7 +404,7 @@ header { opacity: 0 } -.menu-cryp { +.menu-construct { height: 100%; margin: 0.5em; box-sizing: border-box; @@ -512,7 +517,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 39707849..17323160 100644 --- a/client/assets/styles/styles.mobile.css +++ b/client/assets/styles/styles.mobile.css @@ -1,6 +1,6 @@ @media (max-height: 800px), (max-width: 1000px) { - #cryps { - font-size: 12pt; + #constructs { + font-size: 8pt; padding: 0; grid-template-columns: min-content 1fr; grid-template-rows: min-content 1fr; @@ -9,6 +9,10 @@ "main main"; } + button { + font-size: 8pt; + } + table td { height: 2.5em; } @@ -27,15 +31,8 @@ -moz-transition: all 0.5s ease-in-out; -o-transition: all 0.5s ease-in-out; transition: all 0.5s ease-in-out; + } - } -/* main { - -webkit-transition: all 0.5s ease-in-out; - -moz-transition: all 0.5s ease-in-out; - -o-transition: all 0.5s ease-in-out; - transition: all 0.5s ease-in-out; - } -*/ #toggle-nav { display: none; } #toggle-nav-label { diff --git a/client/index.html b/client/index.html index 58b3d1d7..f2a78170 100644 --- a/client/index.html +++ b/client/index.html @@ -1,12 +1,12 @@ - cryps.gg - mnml pvp atbs + mnml.gg - + 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/construct.spawn.button.jsx similarity index 79% rename from client/src/components/cryp.spawn.button.jsx rename to client/src/components/construct.spawn.button.jsx index a4f0e5bb..66e6d225 100644 --- a/client/src/components/cryp.spawn.button.jsx +++ b/client/src/components/construct.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/construct.spawn.container.js b/client/src/components/construct.spawn.container.js new file mode 100644 index 00000000..3ba5b1cf --- /dev/null +++ b/client/src/components/construct.spawn.container.js @@ -0,0 +1,16 @@ +const { connect } = require('react-redux'); + +const ConstructSpawnButton = require('./construct.spawn.button'); + +const addState = connect( + function receiveState(state) { + const { ws } = state; + function sendConstructSpawn(name) { + return ws.sendConstructSpawn(name); + } + + return { account: state.account, sendConstructSpawn }; + } +); + +module.exports = addState(ConstructSpawnButton); diff --git a/client/src/components/cryp.spawn.container.js b/client/src/components/cryp.spawn.container.js deleted file mode 100644 index 9b743b1b..00000000 --- a/client/src/components/cryp.spawn.container.js +++ /dev/null @@ -1,16 +0,0 @@ -const { connect } = require('react-redux'); - -const CrypSpawnButton = require('./cryp.spawn.button'); - -const addState = connect( - function receiveState(state) { - const { ws } = state; - function sendCrypSpawn(name) { - return ws.sendCrypSpawn(name); - } - - return { account: state.account, sendCrypSpawn }; - } -); - -module.exports = addState(CrypSpawnButton); diff --git a/client/src/components/game.component.jsx b/client/src/components/game.component.jsx index 51a33c98..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)} + 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.cryp.jsx b/client/src/components/game.construct.jsx similarity index 61% rename from client/src/components/game.cryp.jsx rename to client/src/components/game.construct.jsx index 89bb2305..f26f8ff3 100644 --- a/client/src/components/game.cryp.jsx +++ b/client/src/components/game.construct.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/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/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.cryps.jsx b/client/src/components/instance.constructs.jsx similarity index 72% rename from client/src/components/instance.cryps.jsx rename to client/src/components/instance.constructs.jsx index 4906520c..7c72e07c 100644 --- a/client/src/components/instance.cryps.jsx +++ b/client/src/components/instance.constructs.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,18 +204,18 @@ 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}
- Damage + Power
Speed @@ -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.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.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/login.component.jsx b/client/src/components/login.component.jsx index 9603f3dc..41465585 100644 --- a/client/src/components/login.component.jsx +++ b/client/src/components/login.component.jsx @@ -1,11 +1,10 @@ // eslint-disable-next-line const preact = require('preact'); +const { useState } = require('preact/hooks'); -function renderLogin({ submitLogin, submitRegister, submitDemo }) { - const details = { - name: '', - password: '', - }; +function renderLogin({ submitLogin, submitRegister }) { + const [name, setName] = useState(''); + const [password, setPassword] = useState(''); return (
@@ -13,28 +12,28 @@ function renderLogin({ submitLogin, submitRegister, submitDemo }) { className="login-input" type="email" placeholder="username" - onChange={e => (details.name = e.target.value)} + onInput={e => setName(e.target.value)} /> (details.password = e.target.value)} + onInput={e => setPassword(e.target.value)} />
); diff --git a/client/src/components/login.container.jsx b/client/src/components/login.container.jsx index 8d8a75e1..0cba679e 100644 --- a/client/src/components/login.container.jsx +++ b/client/src/components/login.container.jsx @@ -9,12 +9,10 @@ const addState = connect( return ws.sendAccountLogin(name, password); } function submitRegister(name, password) { + console.log(name, password); return ws.sendAccountCreate(name, password); } - function submitDemo() { - return ws.sendAccountDemo(); - } - return { account: state.account, submitLogin, submitRegister, submitDemo }; + return { account: state.account, submitLogin, submitRegister }; }, ); 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 b6bdfb03..30a99040 100644 --- a/client/src/components/nav.jsx +++ b/client/src/components/nav.jsx @@ -1,9 +1,12 @@ const { connect } = require('react-redux'); const preact = require('preact'); +const { Fragment } = require('preact'); const actions = require('../actions'); -const testGame = require('./../test.game'); -const testInstance = require('./../test.instance'); +const testGame = process.env.NODE_ENV === 'development' && require('./../test.game'); +const testInstance = process.env.NODE_ENV === 'development' && require('./../test.instance'); + +console.log('env', process.env.NODE_ENV); const addState = connect( function receiveState(state) { @@ -12,7 +15,7 @@ const addState = connect( account, instances, team, - cryps, + constructs, game, } = state; @@ -24,7 +27,7 @@ const addState = connect( account, instances, team, - cryps, + constructs, game, sendInstanceState, }; @@ -57,7 +60,7 @@ function Nav(args) { account, sendInstanceState, team, - cryps, + constructs, instances, game, @@ -78,12 +81,21 @@ 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 ; }); + const haxSection = process.env.NODE_ENV === 'development' + ? ( + +

Hax

+ + +
) + : null; + 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 ( '; - toast.info({ - theme: 'dark', - color: 'black', - timeout: false, - drag: false, - position: 'center', - maxWidth: window.innerWidth / 2, - close: false, - buttons: [ - [OK_BUTTON, (instance, thisToast) => instance.hide({ transitionOut: 'fadeOut' }, thisToast)], - ], - message, - }); - } - - function loginPrompt() { - const USER_INPUT = ''; - const PASSWORD_INPUT = ''; - const LOGIN_BUTTON = ''; - const REGISTER_BUTTON = ''; - const DEMO_BUTTON = ''; - - const ws = registry.get('ws'); - - function submitLogin(instance, thisToast, button, e, inputs) { - const USERNAME = inputs[0].value; - const PASSWORD = inputs[1].value; - ws.sendAccountLogin(USERNAME, PASSWORD); - } - - function submitRegister(instance, thisToast, button, e, inputs) { - const USERNAME = inputs[0].value; - const PASSWORD = inputs[1].value; - ws.sendAccountCreate(USERNAME, PASSWORD); - } - - function submitDemo() { - ws.sendAccountDemo(); - } - - const existing = document.querySelector('#login'); // Selector of your toast - if (existing) toast.hide({}, existing, 'reconnect'); - - toast.question({ - id: 'login', - theme: 'dark', - color: 'black', - timeout: false, - // overlay: true, - drag: false, - close: false, - title: 'LOGIN', - position: 'center', - inputs: [ - [USER_INPUT, 'change', () => true, true], // true to focus - [PASSWORD_INPUT, 'change', () => true], - ], - buttons: [ - [LOGIN_BUTTON, submitLogin], // true to focus - [REGISTER_BUTTON, submitRegister], // true to focus - [DEMO_BUTTON, submitDemo], // true to focus - ], - }); - - events.once('ACCOUNT', function closeLoginCb() { - const prompt = document.querySelector('#login'); // Selector of your toast - if (prompt) toast.hide({ transitionOut: 'fadeOut' }, prompt, 'event'); - }); - } - - events.on('CRYP_SPAWN', function spawnPrompt() { - const NAME_INPUT = ''; - const SPAWN_BUTTON = ''; - - const ws = registry.get('ws'); - - function submitSpawn(instance, thisToast, button, e, inputs) { - const NAME = inputs[0].value; - ws.sendCrypSpawn(NAME); - instance.hide({ transitionOut: 'fadeOut' }, thisToast, 'button'); - } - - toast.question({ - theme: 'dark', - color: 'black', - timeout: false, - // overlay: true, - drag: false, - close: true, - title: 'SPAWN CRYP', - position: 'center', - inputs: [ - [NAME_INPUT, 'change', null, true], // true to focus - ], - buttons: [ - [SPAWN_BUTTON, submitSpawn], // true to focus - ], - }); - }); - - tutorial('welcome'); - - return { - errorPrompt, - loginPrompt, - setAccount, - setActiveSkill, - setCryps, - setCrypList, - setGame, - setMenu, - setPlayer, - setPlayerList, - setVbox, - setWs, - setGameList, - setZone, - setScores, - }; -} - -module.exports = registerEvents; diff --git a/phaser-client/src/main.js b/phaser-client/src/main.js deleted file mode 100644 index 7a0adc64..00000000 --- a/phaser-client/src/main.js +++ /dev/null @@ -1,17 +0,0 @@ -const renderCryps = require('./scenes/cryps'); - -const createSocket = require('./socket'); -const registerEvents = require('./events'); -const createTutorial = require('./tutorial'); - -document.fonts.load('10pt "Jura"').then(() => { - const game = renderCryps(); - const tutorial = createTutorial(); - const events = registerEvents(game.registry, game.events, tutorial); - const ws = createSocket(events); - - // events.setWs(ws); - // events.setGameList([]); - - ws.connect(); -}); diff --git a/phaser-client/src/scenes/avatar.js b/phaser-client/src/scenes/avatar.js deleted file mode 100644 index 0ca54da0..00000000 --- a/phaser-client/src/scenes/avatar.js +++ /dev/null @@ -1,13 +0,0 @@ -const genAvatar = (name) => { - let hash = 0; - if (name.length === 0) return hash; - // Probs don't need to hash using the whole string - for (let i = 0; i < name.length; i += 1) { - const chr = name.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash = hash & 10000; // We have avatars named 0-19 - } - return `sprite${hash}`; -}; - -module.exports = genAvatar; diff --git a/phaser-client/src/scenes/background.js b/phaser-client/src/scenes/background.js deleted file mode 100644 index 7baaadd7..00000000 --- a/phaser-client/src/scenes/background.js +++ /dev/null @@ -1,166 +0,0 @@ -const Phaser = require('phaser'); - -const CHART = ` -#ifdef GL_ES -precision mediump float; -#endif - -#extension GL_OES_standard_derivatives : enable - -uniform float time; -uniform vec2 mouse; -uniform vec2 resolution; - -float rand(float n){return fract(sin(n) * 43758.5453123 * time * 0.00001);} - -float noise(float p){ - float fl = floor(p); - float fc = fract(p); - // return mix(rand(fl), rand(fl + 1.0), p); - return mix(rand(fl), rand(fl + 1.0), p); -} - -float getLine(vec2 p, float y){ - float margin = 0.; - - vec2 pos = p; - float a = time * 100. + y * 31.; - vec2 lineCenter = vec2(0.5, y); - - pos -= lineCenter; - pos *- mat2(cos(a), -sin(a), sin(a), cos(a)); - pos += lineCenter; - - - float marginb = 0.005; - float b = 0.004; - float t = y + (noise((pos.x + y) * 100.) - 0.5) * 0.02; - float f = (smoothstep(t - b, t, pos.y) - smoothstep(t, t + b, pos.y)); - f *= smoothstep(margin - marginb, margin, pos.x) - smoothstep(1. - margin, 1. - margin + marginb, pos.x); - f *= 0.8; - - float light = 0.5 + 0.5 * sin(time * .2); - vec2 point = vec2(margin + light * (1. - margin * 2.), t); - f += .008 / distance(pos, point); - return f; -} - -void main( void ) { - vec2 p = gl_FragCoord.xy / resolution.xy; - float f = 0.; - - for(int i = 0; i < 10; i++){ - f += getLine(p, 0.1 + (0.8) / 10. * float(i)); - } - - vec3 color = vec3(0., .4, .6) * f; - gl_FragColor = vec4(color, 1.); -}`; - -const STARS = ` -//--- hatsuyuki --- -// by Catzpaw 2016 -#ifdef GL_ES -precision mediump float; -#endif - -#extension GL_OES_standard_derivatives : enable - -uniform float time; -uniform vec2 resolution; - float hash(float x){ - return fract(sin(x*133.3)*12.13); - } - void main(void){ - vec2 uv=(gl_FragCoord.xy*2.-resolution.xy)/min(resolution.x,resolution.y); - vec3 c=vec3(.2,.2,.2); - float a=4.4; - float si=sin(a),co=cos(a); - uv*=mat2(co,-si,si,co); - uv*=length(uv+vec2(0,1.9))*.5+1.; - float v=1.-sin(hash(floor(uv.x*200.))*2.); - float b=clamp(abs(sin(5.*time*v+uv.y*(5./(2.+v))))-.95,0.,1.)*20.; - c*=v*b; - gl_FragColor = vec4(c,2); -} -`; - -const PLASMA = ` -precision mediump float; - -uniform sampler2D uMainSampler; -uniform vec2 resolution; -uniform float time; - -varying vec2 outTexCoord; -varying vec4 outTint; - -#define MAX_ITER 4 - -void main( void ) -{ - vec2 v_texCoord = gl_FragCoord.xy / resolution; - - vec2 p = v_texCoord * 8.0 - vec2(20.0); - vec2 i = p; - float c = 1.0; - float inten = .05; - - for (int n = 0; n < MAX_ITER; n++) - { - float t = time * (1.0 - (3.0 / float(n+1))); - - i = p + vec2(cos(t - i.x) + sin(t + i.y), - sin(t - i.y) + cos(t + i.x)); - - c += 1.0/length(vec2(p.x / (sin(i.x+t)/inten), - p.y / (cos(i.y+t)/inten))); - } - - c /= float(MAX_ITER); - c = 1.5 - sqrt(c); - - vec4 texColor = vec4(0.01, 0.01, 0.01, 1.0); - - texColor.rgb *= (1.0 / (1.0 - (c + 0.05))); - - gl_FragColor = texColor; -} -`; - -const CustomPipeline = new Phaser.Class({ - Extends: Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline, - initialize: function CustomPipeline (game) { - Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline.call(this, { - game, - renderer: game.renderer, - fragShader: STARS, - }); - }, -}); - - -class Background extends Phaser.Scene { - constructor() { - super({ key: 'Background', active: true }); - this.bgTime = 10.0; - } - - create() { - const game = this.game; - this.customPipeline = game.renderer.addPipeline('Custom', new CustomPipeline(game)); - this.customPipeline.setFloat2('resolution', 1600, 1000); - - const sprite = this.add.sprite(800, 500); - sprite.setPipeline('Custom'); - sprite.displayWidth = 1600 * window.devicePixelRatio; - sprite.displayHeight = 1000 * window.devicePixelRatio; - } - - update() { - this.customPipeline.setFloat1('time', this.bgTime); - this.bgTime += 0.005; - } -} - -module.exports = Background; diff --git a/phaser-client/src/scenes/combat.animations.js b/phaser-client/src/scenes/combat.animations.js deleted file mode 100644 index 58fae31d..00000000 --- a/phaser-client/src/scenes/combat.animations.js +++ /dev/null @@ -1,250 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { COMBAT }, DELAYS } = require('./constants'); - -const randomColour = () => { - const colours = ['green', 'blue', 'red', 'white', 'yellow']; - return colours[Math.floor(Math.random() * 5)]; -}; - -const animationParams = (sourceAlly) => { - const spawnLocation = sourceAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65; - const speed = sourceAlly ? 250 : -250; - const img = randomColour(); - const angleMin = sourceAlly ? 320 : 180; - const angleMax = sourceAlly ? 360 : 220; - return { spawnLocation, speed, img, angleMin, angleMax }; -}; - -const randomAttack = () => { - const animations = ['wall', 'spit', 'gravBlast', 'gravBomb', 'chargeBall']; - return animations[Math.floor(Math.random() * 5)]; -}; - -class CombatSkills extends Phaser.GameObjects.Group { - constructor(scene) { - super(scene); - this.scene = scene; - } - - getSkill(type, sourceAlly, targetAlly, castLocation) { - const genericHeal = ['Heal', 'Triage', 'TriageTick', 'DecayTick']; - const genericBlock = ['Block', 'Parry', 'Evasion', 'Shield']; - - if (genericHeal.includes(type)) { - this.genericHeal(targetAlly, castLocation); - } else if (genericBlock.includes(type)) { - this.genericBlock(sourceAlly); - } else { - this[randomAttack()](sourceAlly); - } - } - - genericHeal(sourceAlly, castLocation) { - // const { sourceX, sourceY } = getCrypPosition(sourcePos, 0); - const lifespan = DELAYS.ANIMATION_DURATION; - const colour = randomColour(); - const particles = this.scene.add.particles(colour); - const x = sourceAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7; - - const emitter2 = particles.createEmitter({ - x: castLocation.x, - y: castLocation.y, - moveToX: x, - moveToY: COMBAT.height() * 0.2, - speed: 500, - lifespan: lifespan / 3, - scale: { start: 0.5, end: 1 }, - quantity: 3, - _frequency: 20, - blendMode: 'ADD', - emitZone: { source: new Phaser.Geom.Rectangle(-200, -100, 400, 200) }, - }); - - const emitter = particles.createEmitter({ - x, - y: COMBAT.height() * 0.2, - angle: { min: 250, max: 290 }, - speed: 250, - gravityY: 1000, - quantity: 4, - scale: { start: 0.1, end: 1 }, - blendMode: 'ADD', - lifespan, - active: false, - }); - - - this.add(particles); - this.scene.time.delayedCall(lifespan / 3, () => { emitter2.stop(); }, [], this); - this.scene.time.delayedCall(lifespan / 3, () => { emitter.active = true; }, [], this); - - this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this); - } - - genericBlock(sourceAlly) { - const lifespan = DELAYS.ANIMATION_DURATION; - const colour = randomColour(); - const x = sourceAlly ? COMBAT.width() * 0.3 : COMBAT.width() * 0.7; - const emitter1 = this.scene.add.particles(colour).createEmitter({ - x, - y: COMBAT.height() * 0.4, - scale: { start: 0.75, end: 0.25 }, - blendMode: 'ADD', - emitZone: { - source: new Phaser.Geom.Rectangle(-100, -100, 200, 200), - type: 'edge', - quantity: 24, - yoyo: true, - }, - }); - const emitter2 = this.scene.add.particles(colour).createEmitter({ - x, - y: COMBAT.height() * 0.4, - blendMode: 'SCREEN', - scale: { start: 0.2, end: 0 }, - speed: { min: -100, max: 100 }, - quantity: 50, - active: false, - emitZone: { - source: new Phaser.Geom.Rectangle(-100, -100, 200, 200), - type: 'edge', - quantity: 50, - }, - }); - this.scene.time.delayedCall(lifespan / 2, () => { emitter1.stop(); }, [], this); - this.scene.time.delayedCall(lifespan / 2, () => { emitter2.active = true; }, [], this); - this.scene.time.delayedCall(lifespan, () => { emitter2.stop(); }, [], this); - } - - wall(sourceAlly) { - const lifespan = DELAYS.ANIMATION_DURATION; - const { spawnLocation, speed, img } = animationParams(sourceAlly); - const particles = this.scene.add.particles(img); - const emitter = particles.createEmitter({ - x: spawnLocation, - y: { min: COMBAT.height() * 0.2, max: COMBAT.height() * 0.5 }, - speedX: { min: speed, max: speed * 2 }, - scale: { start: 0.4, end: 0 }, - quantity: 4, - blendMode: 'ADD', - lifespan, - }); - this.add(particles); - this.scene.time.delayedCall(1000, () => { emitter.stop(); }, [], this.scene); - } - - spit(sourceAlly) { - const lifespan = DELAYS.ANIMATION_DURATION; - const { spawnLocation, speed, img, angleMin, angleMax } = animationParams(sourceAlly); - const particles = this.scene.add.particles(img); - const emitter = particles.createEmitter({ - x: spawnLocation, - y: COMBAT.height() * 0.35, - angle: { min: angleMin, max: angleMax }, - speed: speed * 2, - scale: { start: 0.4, end: 1 }, - gravityY: 250, - quantity: 4, - blendMode: 'ADD', - lifespan, - }); - this.add(particles); - this.scene.time.delayedCall(lifespan, () => { emitter.stop(); }, [], this); - } - - gravBomb(sourceAlly) { - const lifespan = DELAYS.ANIMATION_DURATION; - - const { spawnLocation, img } = animationParams(!sourceAlly); - const particles = this.scene.add.particles(img); - const well = particles.createGravityWell({ - x: spawnLocation, - y: COMBAT.height() * 0.25, - power: 4, - gravity: 500, - }); - this.emitter = particles.createEmitter({ - x: spawnLocation, - y: COMBAT.height() * 0.25, - speed: 1000, - scale: { start: 0.7, end: 1 }, - blendMode: 'ADD', - lifespan, - }); - this.add(particles); - this.scene.time.delayedCall(lifespan, () => { this.emitter.stop(); well.active = false; }, [], this.scene); - } - - gravBlast(sourceAlly) { - const lifespan = DELAYS.ANIMATION_DURATION; - const WELL_END = lifespan / 2; - - const img = randomColour(); - const spawnLocation = sourceAlly ? COMBAT.width() * 0.35 : COMBAT.width() * 0.65; - const isEnemyLocation = sourceAlly ? COMBAT.width() * 0.7 : COMBAT.width() * 0.3; - const particles = this.scene.add.particles(img); - const bounds = sourceAlly - ? { x: COMBAT.width() * 0.3, y: COMBAT.height() * 0.2, w: COMBAT.width() * 0.5, h: COMBAT.height() * 0.2 } - : { x: 0.2 * COMBAT.width(), y: COMBAT.height() * 0.2, w: COMBAT.width() * 0.5, h: COMBAT.height() * 0.2 }; - const well = particles.createGravityWell({ - x: spawnLocation, - y: COMBAT.height() * 0.35, - power: 4, - gravity: 500, - }); - const emitter = particles.createEmitter({ - x: spawnLocation, - y: COMBAT.height() * 0.35, - speed: 1000, - scale: { start: 0.7, end: 1 }, - blendMode: 'ADD', - bounds, - lifespan, - }); - this.add(particles); - this.scene.time.delayedCall(WELL_END, () => { emitter.stop(); well.x = isEnemyLocation; }, [], this.scene); - this.scene.time.delayedCall(lifespan, () => { well.active = false; }, [], this.scene); - } - - chargeBall(sourceAlly) { - const lifespan = DELAYS.ANIMATION_DURATION; - const CHARGE_LIFESPAN = lifespan / 3; - - const { img, spawnLocation } = animationParams(sourceAlly); - const targetLocation = sourceAlly ? 0.7 * COMBAT.width() : 0.25 * COMBAT.width(); - const particles = this.scene.add.particles(img); - const emitter = particles.createEmitter({ - x: 0, - y: 0, - moveToX: spawnLocation, - moveToY: COMBAT.height() * 0.1, - scale: 0.75, - quantity: 4, - _frequency: 20, - blendMode: 'ADD', - emitZone: { source: new Phaser.Geom.Rectangle(0, 0, COMBAT.width(), COMBAT.height()) }, - lifespan: CHARGE_LIFESPAN, - }); - const emitter2 = particles.createEmitter({ - radial: false, - x: { min: spawnLocation, max: targetLocation, steps: 90 }, - y: { min: COMBAT.height() * 0.1, max: COMBAT.height() * 0.4, steps: 90 }, - quantity: 4, - gravityY: 0, - scale: { start: 2, end: 0.1, ease: 'Power3' }, - blendMode: 'ADD', - active: false, - lifespan: CHARGE_LIFESPAN, - }); - this.add(particles); - this.scene.time.delayedCall(CHARGE_LIFESPAN, () => { emitter.stop(); }, [], this.scene); - this.scene.time.delayedCall(CHARGE_LIFESPAN * 2, () => { emitter2.active = true; }, [], this.scene); - this.scene.time.delayedCall(lifespan, () => { emitter2.stop(); }, [], this.scene); - } - - cleanup() { - this.children.entries.forEach(obj => obj.destroy()); - } -} - -module.exports = CombatSkills; diff --git a/phaser-client/src/scenes/combat.cryps.js b/phaser-client/src/scenes/combat.cryps.js deleted file mode 100644 index 9112d2ad..00000000 --- a/phaser-client/src/scenes/combat.cryps.js +++ /dev/null @@ -1,239 +0,0 @@ -const Phaser = require('phaser'); -const genAvatar = require('./avatar'); -const StatBar = require('./elements/combat.statbar'); - -const { DELAYS, TEXT, POSITIONS: { COMBAT } } = require('./constants'); - -const CRYP_MARGIN = COMBAT.crypMargin(); -const TEXT_MARGIN = COMBAT.textMargin(); - -const crypAvatarText = (team, iter) => { - const nameX = COMBAT.width() * team; - const nameY = COMBAT.y() + CRYP_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; - 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 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 }; -}; - - -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; - this.effectCount = 0; - } - - addEffect(effect) { - const y = this.y + this.effectCount * TEXT_MARGIN; - const text = `${effect.effect} for ${effect.duration} turn`; - const e = this.scene.add.text(this.x, y, text, TEXT.NORMAL); - e.effect = effect.effect; - this.add(e); - this.effectCount += 1; - } - - removeEffect(effect) { - this.children.entries.forEach((e) => { - if (e.effect === effect) e.destroy(); - }); - } - - update(effects) { - this.effectCount = 0; - this.children.entries.forEach(e => e.destroy()); - effects.forEach((effect) => { - this.addEffect(effect); - }); - return true; - } -} - -class CrypImage extends Phaser.GameObjects.Image { - constructor(scene, team, iter, cryp) { - // Get coords - const { crypAvatarX, crypAvatarY } = crypPosition(team, iter); - const { statusX, statusY, nameX, nameY } = crypAvatarText(team, iter); - - // Cryp display - // const avatar = team ? 'magmar' : 'alk'; - super(scene, crypAvatarX, crypAvatarY, 'aztec', genAvatar(cryp.name)); - this.setScale(0.5); - - if (!team) this.flipX = true; - - // Save position and cryp details - this.scene = scene; - this.iter = iter; - this.team = team; - this.cryp = cryp; - this.state = 'deselect'; - // Add cryp name - scene.add.text(nameX, nameY, cryp.name, TEXT.NORMAL).setOrigin(team, 0); - // Add cryp 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')); - // this.evasion = scene.add.existing(new StatBar(scene, this, 'Evasion')); - - this.effects = scene.add.existing(new Effects(scene, team, iter)); - this.statusText = scene.add.text(statusX, statusY, '', TEXT.NORMAL); - } - - select() { - this.setTint('0x00bb00'); - this.state = 'select'; - } - - setKo() { - this.state = 'ko'; - this.setTint('0x9d9ea0'); - } - - deselect() { - if (this.state !== 'ko') { - this.clearTint(); - this.state = 'deselect'; - } - } - - clearStatus() { - this.statusText.text = ''; - } - - reduceDefense(amount, type) { - if (type === 'PhysDmg') { - this.red_shield.takeDamage(amount); - } else if (type === 'BlueDmg') { - this.blue_shield.takeDamage(amount); - } - } - - takeDamage(props) { - const { amount, mitigation, category } = props; - if (mitigation) this.reduceDefense(mitigation, category); - this.setTint(0xff0000); - this.health.takeDamage(amount); - this.scene.time.delayedCall(DELAYS.DAMAGE_TICK, () => { - if (this.state !== 'ko') this.clearTint(); - }); - } - - takeHealing(amount) { - this.setTint(0x00bb00); - this.health.takeDamage(amount * -1); - this.scene.time.delayedCall(DELAYS.DAMAGE_TICK, () => { - if (this.state !== 'ko') this.clearTint(); - }); - } -} - -class CombatCryps extends Phaser.Scene { - constructor() { - super({ key: 'CombatCryps' }); - } - - create(game) { - this.cryps = this.add.group(); - this.phase = game.phase; - this.account = this.registry.get('account'); - this.drawCryps(game); - this.registry.events.on('changedata', this.updateData, this); - this.registry.set('crypStatusUpdate', false); - this.teams = game.teams.length; - } - - updateData(parent, key, data) { - if (key === 'game' && data) { - if (data.teams.length !== this.teams) this.scene.restart(data); - const isAnimating = this.phase === 'animating'; - this.game = data; - if (isAnimating) return false; - } - - if (key === 'gamePhase' && data) { - const shouldUpdate = data !== this.phase; - this.phase = data; - if (shouldUpdate) { - this.cryps.children.entries.forEach(c => c.clearStatus()); - this.drawCryps(this.game); - } - } - - if (key === 'crypStatusUpdate' && data) { - this.updateCrypStatus(data); - } - - return true; - } - - drawCryps(game) { - const renderCryp = (cryp, 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 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; - - crypObj.health.drawStatBar(); - crypObj.red_shield.drawStatBar(); - crypObj.blue_shield.drawStatBar(); - crypObj.effects.update(cryp.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)); - if (!enemyTeam) return false; - enemyTeam.cryps.forEach((cryp, i) => renderTeam(cryp, 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(); - } - - updateCrypStatus(status) { - const sourceCryp = this.cryps.children.entries - .find(c => c.cryp.id === status.id); - - const targetCryp = this.cryps.children.entries - .find(c => c.cryp.id === status.target); - - if (this.phase === 'Skill') { - sourceCryp.statusText.text = `${status.skill} on ${targetCryp.cryp.name}`; - } - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData); - this.scene.remove(); - } -} - -module.exports = CombatCryps; diff --git a/phaser-client/src/scenes/combat.hitbox.js b/phaser-client/src/scenes/combat.hitbox.js deleted file mode 100644 index 392cbc0c..00000000 --- a/phaser-client/src/scenes/combat.hitbox.js +++ /dev/null @@ -1,89 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { COMBAT } } = require('./constants'); - -const CRYP_MARGIN = COMBAT.crypMargin(); -const BOX_HEIGHT = CRYP_MARGIN * 0.8; -const BOX_WIDTH = COMBAT.width() * 0.2; - - -class CrypHitBox extends Phaser.GameObjects.Rectangle { - constructor(scene, iter, team, cback) { - const y = COMBAT.y() + COMBAT.height() * 0.05 + CRYP_MARGIN * iter; - super(scene, (COMBAT.width() - BOX_WIDTH) * team, y, BOX_WIDTH, BOX_HEIGHT, 0x222222); - this.setOrigin(0); - this.clickHandler = () => cback(); - } - - select() { - this.setFillStyle(0x003300); - } - - deselect() { - this.setFillStyle(0x222222); - } -} - -class CombatHitBox extends Phaser.Scene { - constructor() { - super({ key: 'CombatHitBox' }); - } - - create(phase) { - this.phase = phase; - this.registry.events.off('changedata', this.updateData); - this.registry.events.on('changedata', this.updateData, this); - if (phase === 'animating') return true; - this.selectHitBox(phase); - return true; - } - - updateData(parent, key, data) { - if (key === 'game' && data) { - // In the case that we hit skill phase but teams change we restart - if (data.teams.length !== this.teams) this.scene.restart(data.phase); - } - if (key === 'gamePhase' && data) { - const shouldUpdate = data !== this.phase; - if (shouldUpdate) this.scene.restart(data); - return false; - } - return true; - } - - selectHitBox(phase) { - const game = this.registry.get('game'); - this.teams = game.teams.length; - if (phase === 'Skill') return this.skillHitBox(game); - return false; - } - - skillHitBox(game) { - const account = this.registry.get('account'); - const group = this.scene.get('CombatCryps').cryps; - const skillScene = this.scene.get('CombatSkills'); - game.teams.forEach((t) => { - t.cryps.forEach((c) => { - const cback = () => { - const { activeSkill } = skillScene; - if (activeSkill) { - this.scene.get('CombatSkills').clearCrypActive(activeSkill.cryp.id); - activeSkill.activate(); - skillScene.activeSkill = null; - this.game.events.emit('SEND_SKILL', game.id, activeSkill.cryp.id, c.id, activeSkill.skill.skill); - } - }; - const crypSpawn = group.children.entries.find(s => s.cryp.id === c.id); - const team = c.account === account.id ? 0 : 1; - if (crypSpawn) this.add.existing(new CrypHitBox(this, crypSpawn.iter, team, cback)); - }); - }); - this.scene.moveBelow('Combat'); - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData); - this.scene.remove(); - } -} - -module.exports = CombatHitBox; diff --git a/phaser-client/src/scenes/combat.js b/phaser-client/src/scenes/combat.js deleted file mode 100644 index dd8a39a9..00000000 --- a/phaser-client/src/scenes/combat.js +++ /dev/null @@ -1,138 +0,0 @@ -const Phaser = require('phaser'); -const { throttle } = require('lodash'); - -const { TEXT, POSITIONS: { COMBAT } } = require('./constants'); -const CombatLog = require('./combat.log'); -const CombatCryps = require('./combat.cryps'); -const CombatSkills = require('./combat.skills'); -const CombatHitBox = require('./combat.hitbox'); - -const renderResolutions = require('./combat.render.resolutions'); - - -class Combat extends Phaser.Scene { - constructor() { - super({ key: 'Combat' }); - } - - preload() { - this.load.image('proj', 'https://labs.phaser.io/assets/sprites/bullet.png'); - this.load.image('blue', 'https://labs.phaser.io/assets/particles/blue.png'); - this.load.image('green', 'https://labs.phaser.io/assets/particles/green.png'); - this.load.image('red', 'https://labs.phaser.io/assets/particles/red.png'); - this.load.image('white', 'https://labs.phaser.io/assets/particles/white.png'); - this.load.image('yellow', 'https://labs.phaser.io/assets/particles/yellow.png'); - } - - create() { - console.log('creating game'); - this.registry.events.off('changedata', this.updateData); - this.registry.events.on('changedata', this.updateData, this); - this.addLeaveGame(); - - this.registry.set('gamePhase', false); - this.registry.set('inGame', true); - this.registry.set('gameAnimating', false); - this.account = this.registry.get('account'); - this.fetchGame = throttle(() => { - const game = this.registry.get('game'); - if (game) { - const ws = this.registry.get('ws'); - return ws.sendGameState(game.id); - } - return false; - }, 500); - - return true; - } - - startGame(game) { - this.scene.manager.add('CombatCryps', CombatCryps, 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); - this.scene.manager.add('CombatHitBox', CombatHitBox, true, game.phase); - this.registry.set('gamePhase', game.phase); - this.phase = game.phase; - return true; - } - - update() { - this.fetchGame(); - return true; - } - - updateData(parent, key, data) { - if (key === 'game') { - if (!data) return false; - const startGame = this.registry.get('gamePhase') === false; - if (startGame) { this.startGame(data); return true; } - this.checkAnimation(data); - // Game over? - // if (data.phase === 'Finish') { - // this.time.delayedCall(10000, () => { - // this.endGame(); - // }); - // } - } - return true; - } - - checkAnimation(game) { - // Check cryps are loaded and whether game is animating - const cantAnimate = this.registry.get('gamePhase') === 'animating'; - if (cantAnimate) return false; - if (game.resolved.length !== this.renderedResolves) { - const newResolutions = game.resolved.slice(this.renderedResolves); - renderResolutions(this, game, newResolutions); - this.renderedResolves = game.resolved.length; - return true; - } - if (this.phase !== game.phase) { - this.phase = game.phase; - this.registry.set('gamePhase', game.phase); - } - if (this.registry.get('gameLog') !== game.log.length) { - this.registry.set('gameLog', game.log.length); - } - return true; - } - - addLeaveGame() { - const leaveGame = () => this.cleanUp(); - this.input.keyboard.on('keydown_BACKSPACE', leaveGame, 0, this); - const LEAVE_HEIGHT = COMBAT.height() / 6; - const LEAVE_WIDTH = COMBAT.width() / 5; - const LEAVE_X = COMBAT.width() * 0.8; - const LEAVE_Y = COMBAT.height() * 0.9; - - const menu = this.add - .rectangle(LEAVE_X, LEAVE_Y, LEAVE_WIDTH, LEAVE_HEIGHT, 0x440000) - .setInteractive() - .setOrigin(0) - .on('pointerdown', leaveGame); - - this.add - .text(menu.getCenter().x, menu.getCenter().y, 'Menu', TEXT.HEADER) - .setOrigin(0.5, 0.5); - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData, this); - this.registry.events.off('setdata', this.updateData, this); - - this.registry.set('inGame', null); - this.registry.set('menu', true); - this.registry.set('game', null); - - const ACTIVE_SCENES = ['CombatLog', 'CombatCryps', 'CombatSkills', 'CombatHitBox']; - ACTIVE_SCENES.forEach((sKey) => { - if (this.scene.get(sKey)) this.scene.get(sKey).cleanUp(); - }); - this.scene.remove(); - - return true; - } -} - -module.exports = Combat; diff --git a/phaser-client/src/scenes/combat.log.js b/phaser-client/src/scenes/combat.log.js deleted file mode 100644 index 7b353ef4..00000000 --- a/phaser-client/src/scenes/combat.log.js +++ /dev/null @@ -1,50 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { COMBAT }, TEXT } = require('./constants'); - -class CombatLog extends Phaser.Scene { - constructor() { - super({ key: 'CombatLog' }); - } - - create(game) { - this.registry.events.on('changedata', this.updateData, this); - this.cameras.main.setViewport(COMBAT.LOG.x(), COMBAT.LOG.y(), COMBAT.LOG.width(), COMBAT.LOG.height()); - this.log = this.add.text(0, 0, '', TEXT.NORMAL); - this.logIndex = game.log.length; - this.logData = game.log; - this.log.setWordWrapWidth(COMBAT.LOG.width()); - this.log.setText(Array.from(game.log).reverse()); - } - - updateData(parent, key, data) { - const UPDATE_KEYS = ['game', 'gameLog']; - if (UPDATE_KEYS.includes(key) && data) { - if (key === 'game') { - this.logData = data.log; - } - if (key === 'gameLog') { - this.logIndex = data; - } - this.updateLog(); - } - return true; - } - - updateLog() { - // shallow copy because reverse mutates - if (this.logData.length > this.logIndex + 1 - && Array.from(this.logData)[this.logIndex].slice(-2) === 'KO') { - this.logIndex += 1; - this.registry.set('gameLog', this.logIndex); - } - // } - this.log.setText(Array.from(this.logData).slice(0, this.logIndex).reverse()); - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData); - this.scene.remove(); - } -} - -module.exports = CombatLog; diff --git a/phaser-client/src/scenes/combat.render.resolutions.js b/phaser-client/src/scenes/combat.render.resolutions.js deleted file mode 100644 index 5ab6918d..00000000 --- a/phaser-client/src/scenes/combat.render.resolutions.js +++ /dev/null @@ -1,135 +0,0 @@ -const { eachSeries } = require('async'); - -const CombatAnimations = require('./combat.animations'); -const { - DELAYS: { ANIMATION_DURATION, MOVE_CREEP, DAMAGE_TICK }, - POSITIONS: { COMBAT }, -} = require('./constants'); - -function findResolutionCryps(scene, group, resolution, game) { - const sourceSpawn = group.children.entries.find(c => c.cryp.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 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 targetSpawn = group.children.entries.find(c => c.cryp.id === resolution.target.id); - - return { sourceSpawn, targetSpawn }; -} - -function calculateTweenParams(sourceSpawn, targetSpawn, account, skill) { - const tweenParams = (targets, centreSpot) => { - const enemy = targets.cryp.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; - const ease = 'Power1'; - const duration = MOVE_CREEP; - return { - targets, x, y, ease, duration, - }; - }; - let moveSourceBattle = false; - let moveSourceOrig = false; - const targetOnlySkill = ['DecayTick']; - if (!(targetOnlySkill.includes(skill))) { - if (sourceSpawn.cryp.account !== targetSpawn.cryp.account) { - moveSourceBattle = tweenParams(sourceSpawn, true); - moveSourceOrig = tweenParams(sourceSpawn, false); - } - } - - const moveTargetBattle = tweenParams(targetSpawn, true); - const moveTargetOrig = tweenParams(targetSpawn, false); - - return { - moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig, - }; -} - -function animatePhase(scene, game, resolution, cb) { - // return early for disabled skills - if (resolution.length === 0) return cb(); - if (resolution.event[0] === 'Disable' - || resolution.event[0] === 'TargetKo' - || resolution.event === 'Ko') return cb(); - - const group = scene.scene.get('CombatCryps').cryps; - const animations = new CombatAnimations(scene); - const account = scene.registry.get('account'); - - // Find cryps, targets - const { sourceSpawn, targetSpawn } = findResolutionCryps(scene, group, resolution, game); - const { - moveSourceBattle, moveSourceOrig, moveTargetBattle, moveTargetOrig, - } = calculateTweenParams(sourceSpawn, targetSpawn, account, resolution.event[1].skill); - - const castParams = () => { - const x = (sourceSpawn === targetSpawn) ? moveTargetBattle.x : sourceSpawn.x; - const y = (sourceSpawn === targetSpawn) ? moveTargetBattle.y : sourceSpawn.y; - return { x, y }; - }; - const castLocation = castParams(); - - // Move cryps 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; - // animate animation - animations.getSkill(resolution.event[1].skill, sourceAlly, targetAlly, castLocation); - // Target cryp takes damage - scene.time.delayedCall(ANIMATION_DURATION, () => { - console.log(resolution); - if (resolution.event[0] === 'Damage') { - targetSpawn.takeDamage(resolution.event[1]); - scene.registry.set('gameLog', scene.registry.get('gameLog') + 1); - } - if (resolution.event[0] === 'Healing') { - targetSpawn.takeHealing(resolution.event[1]); - scene.registry.set('gameLog', scene.registry.get('gameLog') + 1); - } - if (resolution.event[0] === 'Effect') { - targetSpawn.effects.addEffect(resolution.event[1]); - console.log('target has new effect', resolution.event[1].effect); - } - - if (resolution.event[0] === 'Removal') { - targetSpawn.effects.removeEffect(resolution.event[1].effect); - console.log('target effect removed', resolution.event[1].effect); - } - if (moveSourceOrig) scene.tweens.add(moveSourceOrig); - scene.tweens.add(moveTargetOrig); - - // all done - scene.time.delayedCall(MOVE_CREEP, () => { - animations.destroy(true); - return cb(); - }); - }); - }); -} - -function renderResolutions(scene, game, resolutions) { - scene.registry.set('gamePhase', 'animating'); - scene.registry.set('gameLog', scene.registry.get('gameLog') + 1); - - eachSeries( - resolutions, - (resolution, cb) => animatePhase(scene, game, resolution, cb), - (err) => { - if (err) return console.error(err); - scene.registry.set('gamePhase', 'Skill'); - return true; - } - ); - - return true; -} - -module.exports = renderResolutions; diff --git a/phaser-client/src/scenes/combat.skills.js b/phaser-client/src/scenes/combat.skills.js deleted file mode 100644 index b65afa4b..00000000 --- a/phaser-client/src/scenes/combat.skills.js +++ /dev/null @@ -1,235 +0,0 @@ -const Phaser = require('phaser'); - -const { TEXT, POSITIONS: { COMBAT } } = require('./constants'); - -const CRYP_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 TEXT_MARGIN = COMBAT.textMargin(); -const SKILL_WIDTH = COMBAT.width() / 10; -const SKILL_HEIGHT = COMBAT.height() / 30; - -const skillPosition = (crypIter, skillIter) => { - const skillTextX = COMBAT.width() / 3.8; - const skillTextY = (TEXT_MARGIN * skillIter) * 1.5 + CRYP_MARGIN * crypIter + COMBAT.y() + COMBAT.height() * 0.07; - return [skillTextX, skillTextY]; -}; - -const skillCheckHitBox = (scenePlugin, pointer) => { - const { list } = scenePlugin.get('CombatHitBox').children; - for (let i = 0; i < list.length; i += 1) { - if (Phaser.Geom.Rectangle.ContainsPoint(list[i].getBounds(), - pointer.position)) return list[i]; - } - // If we didn't find a hitbox deselect them all - for (let i = 0; i < list.length; i += 1) list[i].deselect(); - return false; -}; - -class CrypSkill extends Phaser.GameObjects.Container { - constructor(scene, x, y, skill, cryp) { - // Avatar will be a property of cryp - super(scene, x, y); - const CD_TEXT = skill.cd ? `(${skill.cd}T)` : ''; - const SKILL_TEXT = `${skill.skill} ${CD_TEXT}`; - this.origX = x; this.origY = y; - - this.skillBox = scene.add.rectangle(0, 0, SKILL_WIDTH, SKILL_HEIGHT, 0x222222); - this.skillText = scene.add.text(0, 0, SKILL_TEXT, TEXT.NORMAL).setOrigin(0.5, 0.5); - this.add(this.skillBox); - this.add(this.skillText); - - this.state = 'deselect'; - this.cryp = cryp; - this.skill = skill; - this.scene = scene; - - this.setSize(SKILL_WIDTH, SKILL_HEIGHT); - this.setInteractive(); - } - - clickHandler() { - if (this.scene.phase === 'Skill') this.scene.activeSkill = this; - this.select(); - } - - select() { - this.scene.children.list.forEach((skill) => { - if (skill.state === 'select') skill.deselect(); - }); - this.skillBox.setFillStyle(0x004bfe); - this.state = 'select'; - } - - activate() { - this.scene.children.list.forEach((skill) => { - if (skill.state === 'select') skill.deselect(); - }); - this.skillBox.setFillStyle(0xff0000); - this.state = 'activate'; - } - - deselect() { - this.skillBox.setFillStyle(0x222222); - this.state = 'deselect'; - } -} - -class CombatSkills extends Phaser.Scene { - constructor() { - super({ key: 'CombatSkills' }); - } - - create(phase) { - this.phase = phase; - this.registry.events.off('changedata', this.updateData); - this.registry.events.on('changedata', this.updateData, this); - this.account = this.registry.get('account'); - - this.input.on('dragstart', (pointer, box) => { - box.clickHandler(); - }); - this.input.on('drag', (pointer, box, dragX, dragY) => { - const hitBox = skillCheckHitBox(this.scene, pointer); - if (hitBox) hitBox.select(); - box.setPosition(dragX, dragY); - }); - this.input.on('dragend', (pointer, box) => { - box.deselect(); - const hitBox = skillCheckHitBox(this.scene, pointer); - if (hitBox) { - hitBox.clickHandler(); - } - box.setPosition(box.origX, box.origY); - }); - - if (phase === 'animating') return true; - // can't set this.game cause of phaser class named the same - const game = this.registry.get('game'); - this.renderSkills(game, phase); - - return true; - } - - updateData(parent, key, data) { - if (key === 'gamePhase' && data) { - const shouldUpdate = data !== this.phase; - if (shouldUpdate) { - this.scene.get('CombatCryps').selectCryp(null); - return this.scene.restart(data); - } - return false; - } - return true; - } - - renderSkills(game, phase) { - if (phase === 'Skill') return this.renderSkillPhase(game); - return false; - } - - renderSkillPhase(game) { - const { account } = this; - const { keyboard } = this.input; - const { events } = this.game; - - const addSkill = (i, j, skill, cryp) => { - const skillTextPos = skillPosition(i, j); - const skillObj = new CrypSkill(this, skillTextPos[0], skillTextPos[1], skill, cryp); - if (skill.cd) { - skillObj.skillBox.setFillStyle(0x9d9ea0); - } else { - this.input.setDraggable(skillObj); - } - this.add.existing(skillObj); - return skillObj; - }; - - const team = game.teams.find(t => t.id === account.id); - const enemyTeam = game.teams.find(t => t.id !== account.id); - - team.cryps.forEach((cryp) => { - // return early if KOd - if (cryp.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); - - // draw the skills - const skillButtons = cryp.skills.map((skill, j) => addSkill(iter, j, skill, cryp)); - - const bindCrypKeys = () => this.mapSkillKeys(skillButtons, game.id, cryp.id, team.id, enemyTeam.id, iter); - - // reset everything - keyboard.on('keydown_ESC', bindCrypKeys, this); - events.on('SEND_SKILL', bindCrypKeys, this); - bindCrypKeys(); - - return true; - }); - - return true; - } - - // FIXME - // needs to send crypId not team - mapSkillKeys(skillButtons, gameId, crypId, alliesId, enemyId, i) { - const { keyboard } = this.input; - - keyboard.removeListener(CRYP_KEY_MAP[i]); - - keyboard.on(CRYP_KEY_MAP[i], () => { - SKILL_KEY_MAP.forEach(k => keyboard.removeListener(k)); - - this.scene.get('CombatCryps').selectCryp(crypId); - - skillButtons.forEach((button, j) => { - keyboard.on(SKILL_KEY_MAP[j], () => { - this.activeSkill = button; - button.select(); - - // clear existing keys - CRYP_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); - button.activate(); - this.activeSkill = null; - this.game.events.emit('SEND_SKILL', gameId, crypId, alliesId, button.skill.skill); - })); - - TARGET_KEY_MAP.forEach(k => keyboard.on(k, () => { - this.clearCrypActive(crypId); - button.activate(); - this.activeSkill = null; - this.game.events.emit('SEND_SKILL', gameId, crypId, enemyId, button.skill.skill); - })); - }, this); - }); - }, this); - - return true; - } - - clearCrypActive(crypId) { - this.scene.scene.children.list.forEach((s) => { - if (s.cryp.id === crypId && 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)); - SKILL_KEY_MAP.forEach(tKey => this.input.keyboard.removeListener(tKey)); - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData); - this.scene.remove(); - } -} - -module.exports = CombatSkills; diff --git a/phaser-client/src/scenes/constants.js b/phaser-client/src/scenes/constants.js deleted file mode 100644 index 8c48cf3b..00000000 --- a/phaser-client/src/scenes/constants.js +++ /dev/null @@ -1,388 +0,0 @@ -// POSITIONING FNS -// floors prevent subpixel rendering which looks trash - -const CANVAS_WIDTH = () => Math.floor(window.innerHeight * 1.6); -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 itemListWidth = () => Math.floor(CANVAS_WIDTH() * 0.5); -const itemListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.95); -const itemListX = () => 0; -const itemListY = () => headerHeight(); -const itemBlockWidth = () => Math.floor(itemListWidth() * 0.12); -const itemBlockHeight = () => Math.floor(itemListHeight() * 0.04); - -const menuNavigationWidth = () => Math.floor(CANVAS_WIDTH() * 0.5); -const menuNavigationHeight = () => Math.floor(CANVAS_HEIGHT() * 0.3); -const menuNavigationX = () => Math.floor(CANVAS_WIDTH() * 0.5); -const menuNavigationY = () => Math.floor(CANVAS_HEIGHT() * 0.7); - -const menuMainWidth = () => Math.floor(CANVAS_WIDTH() * 0.4); -const menuMainHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5); -const menuMainX = () => Math.floor(CANVAS_WIDTH() * 0.65); -const menuMainY = () => headerHeight(); - -const homeMainWidth = () => Math.floor(CANVAS_WIDTH() * 0.6); -const homeMainHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5); -const homeMainX = () => Math.floor(CANVAS_WIDTH() * 0.4); -const homeMainY = () => headerHeight(); - -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 combatTextMargin = () => Math.floor((CANVAS_HEIGHT() - headerHeight()) / 35); - -const statsWidth = () => Math.floor(CANVAS_WIDTH() - menuCrypListWidth()); -const statsHeight = () => CANVAS_HEIGHT() - headerHeight(); -const statsY = () => headerHeight(); -const statsX = () => menuCrypListWidth(); -const statsKnownX = () => Math.floor(statsX() + statsWidth() / 4); -const statsLearnableX = () => Math.floor(statsX() + statsWidth() / 2); -const statsTextMargin = () => 24; -const statsLearnableMargin = () => 12; - -const logWidth = () => Math.floor(combatWidth() * 0.5); -const logHeight = () => Math.floor(combatHeight() * 0.3); -const logY = () => Math.floor(headerHeight() + (combatHeight() * 0.7)); -const logX = () => Math.floor(combatWidth() * 0.2); - - -module.exports = { - TEXT: { - NORMAL: { fontFamily: 'Jura', fontSize: 18, color: '#ffffff' }, - LEARNABLE: { fontFamily: 'Jura', fontSize: 18, color: '#ffffff' }, - HEADER: { fontFamily: 'Jura', fontSize: 24, color: '#ffffff', fontStyle: 'bold' }, - HOVER: { fontFamily: 'Jura', fontSize: 16, color: '#ffffff', backgroundColor: '#222222' }, - }, - - POSITIONS: { - HEADER: { - width: headerWidth, - height: headerHeight, - }, - - CRYP_LIST: { - x: menuCrypListX, - y: menuCrypListY, - width: menuCrypListWidth, - height: menuCrypListHeight, - }, - - MENU_MAIN: { - x: menuMainX, - y: menuMainY, - width: menuMainWidth, - height: menuMainHeight, - - }, - - HOME_MAIN: { - x: homeMainX, - y: homeMainY, - width: homeMainWidth, - height: homeMainHeight, - - }, - - - NAVIGATION: { - x: menuNavigationX, - y: menuNavigationY, - width: menuNavigationWidth, - height: menuNavigationHeight, - }, - - ITEM_LIST: { - x: itemListX, - y: itemListY, - width: itemListWidth, - height: itemListHeight, - itemWidth: itemBlockWidth, - itemHeight: itemBlockHeight, - - }, - - STATS: { - x: statsX, - y: statsY, - width: statsWidth, - height: statsHeight, - knownX: statsKnownX, - learnableX: statsLearnableX, - textMargin: statsTextMargin, - learnableMargin: statsLearnableMargin, - }, - - COMBAT: { - x: combatX, - y: combatY, - width: combatWidth, - height: combatHeight, - crypMargin: combatCrypMargin, - textMargin: combatTextMargin, - - - LOG: { - x: logX, - y: logY, - width: logWidth, - height: logHeight, - }, - }, - }, - - COLOURS: { - BLUE: 0x004bfe, - CYAN: 0x27e7c0, - PURPLE: 0x61008c, - YELLOW: 0xfdfe02, - ORANGE: 0xff9215, - PINK: 0xe766b6, - GRAY: 0x9d9ea0, - LBLUE: 0x87c6f2, - GREEN: 0x166c4f, - BROWN: 0x583108, - BLACK: 0x000000, - RED: 0xff0000, - WHITE: 0xffffff, - - SELECT: 0x003300, - }, - - DELAYS: { - MOVE_CREEP: 500, - DAMAGE_TICK: 500, - ANIMATION_DURATION: 1000, - // wall: [500], - // spit: [300, 500], - // gravBomb: [300, 500], - // gravBlast: [300, 500], - // chargeBall: [300, 500], - }, - - ITEMS: { - SKILLS: { - Amplify: { - description: 'increase the magic damage dealt by a cryp', - colours: '1 Green 1 Blue', - }, - - Attack: { - description: 'a fast attack with red damage', - upgrades: 'combine with 2 red / blue / green - red + blue attack not implemented', - }, - - Banish: { - description: 'target cryp is prevented from casting any skills and taking any damage', - colours: '1 Red 1 Green', - - }, - - Blast: { - description: 'blast the target with magic damage', - colours: '2 Blue', - }, - - Block: { - description: 'decreases incoming red damage for 1T', - upgrades: 'combine with 2 red / blue / green', - }, - - Buff: { - description: 'increase target cryp speed', - upgrades: 'combine with 2 red / blue / green', - }, - - Clutch: { - description: '??????', - colours: '1 Red 1 Green', - }, - - Corrupt: { - description: 'Inflicts a dot to attacker while active', - colours: '2 Blue', - }, - - Curse: { - description: 'target cryp takes increased magic damage', - colours: '2 Blue', - }, - - Debuff: { - description: 'reduce target cryp speed', - upgrades: 'combine with 2 red / blue / green', - }, - - Decay: { - description: 'afflict a cryp with a blue damage based damage over time debuff', - colours: '1 Green 1 Blue', - }, - - Empower: { - description: 'increase the red damage dealt by a cryp', - colours: '2 Red', - }, - - Haste: { - description: 'magical skill that increases speed of target cryp', - colours: '1 Red 1 Blue', - }, - - Heal: { - description: 'heal a cryp with blue damage', - colours: '2 Green', - }, - - Hex: { - description: 'magical bsed skill that prevents target cryp from using any skills', - colours: '1 Red 1 Blue', - }, - - Hostility: { - description: 'magical bsed skill that prevents target cryp from using any skills', - colours: '2 Blue', - }, - - Invert: { - description: 'reverse ???', - colours: '1 Red 1 Blue', - }, - - Parry: { - description: 'prevents all red damage for 1T', - colours: '2 Red', - }, - - Purge: { - description: 'remove magical buffs from target cryp', - colours: '2 Green', - }, - - Purify: { - description: 'remove magical debuffs from target cryp', - colours: '1 Red 1 Green', - }, - - Recharge: { - description: 'restore something', - colours: '1 Red 1 Blue', - }, - - Reflect: { - description: 'reflect damage back to attacker', - colours: '2 Green', - }, - - Riposte: { - description: '???', - }, - - Ruin: { - description: 'Stun the entire enemy team', - colours: '2 Blue', - }, - - Shield: { - description: 'grants immunity to magical skills to target cryp', - colours: '1 Green 1 Blue', - }, - - Silence: { - description: 'prevent target cryp from casting magical skills', - colours: '1 Green 1 Blue', - }, - - Siphon: { - description: 'siphon hp from target cryp with a blue damage based debuff', - colours: '1 Green 1 Blue', - }, - - Slay: { - description: '????', - }, - - Slow: { - description: 'magical skill that reduces speed of target cryp', - colours: '1 Red 1 Green', - }, - - Snare: { - description: 'prevents red skills from being used for 2T', - colours: '2 Red', - }, - - Strangle: { - description: 'Stun the enemy and inflict physical damage over 3T', - colours: '2 Red', - }, - - Strike: { - description: 'Fast attacking red skill', - colours: '2 Red', - }, - - Stun: { - description: 'red skill hat prevents target cryp from using any skills', - upgrades: 'combine with 2 red / blue / green', - - }, - - Taunt: { - description: 'Enemy skills will prioritise cryps with this skill active', - colours: '1 Red 1 Green', - }, - - Throw: { - description: 'stuns and makes the target take increased red damage', - colours: '2 Green', - }, - - Triage: { - description: 'grants a blue damage based healing over time buff', - colours: '2 Green', - }, - }, - - SPECS: { - Damage: { - description: 'Increase red / green / blue power stats cryp', - upgrades: 'combine with 2 red / blue / green', - - }, - - Hp: { - description: 'Increases health of cryp', - upgrades: 'combine with 2 red / blue / green', - - }, - - Speed: { - description: 'Increases speed of cryp', - upgrades: 'combine with 2 red / blue / green', - }, - }, - - COLOURS: { - Red: { - description: 'Used to create offensive type combos - fast and chaotic', - }, - - Green: { - description: 'Used to create defensive / healing type combos', - }, - - Blue: { - description: 'Used to create offensive type combos - slow and reliable', - }, - }, - }, -}; diff --git a/phaser-client/src/scenes/cryps.js b/phaser-client/src/scenes/cryps.js deleted file mode 100644 index b63c0512..00000000 --- a/phaser-client/src/scenes/cryps.js +++ /dev/null @@ -1,77 +0,0 @@ -const Phaser = require('phaser'); - -const Header = require('./header'); -const Home = require('./home'); -const Menu = require('./menu'); -const Combat = require('./combat'); - -// const Background = require('./background'); - -function renderCryps() { - const config = { - type: Phaser.CANVAS, - // backgroundColor: '#181818', - resolution: window.devicePixelRatio, - scale: { - mode: Phaser.Scale.FIT, - width: Math.floor(window.innerHeight * 1.6), - height: Math.floor(window.innerHeight), - max: { - width: Math.floor(window.innerHeight * 1.6), - height: Math.floor(window.innerHeight), - }, - - }, - antialias: true, - physics: { - default: 'arcade', - arcade: { - debug: false, - gravity: { y: 0 }, - }, - }, - scene: [ - // Background, - Header, - ], - }; - - const game = new Phaser.Game(config); - - - function changeData(parent, key, data) { - // Don't load other scenes if you're not logged in - if (!game.registry.get('account')) return false; - - if (key === 'home') { - if (data) return game.scene.add('Home', Home, true); - } - - if (key === 'menu') { - if (!data || game.registry.get('inMenu')) return false; - if (data) return game.scene.add('Menu', Menu, true); - } - - if (key === 'game') { - if (!data || game.registry.get('inGame')) return false; - return game.scene.add('Combat', Combat, true); - } - - return true; - } - - game.registry.events.on('changedata', changeData); - game.registry.events.on('setdata', changeData); - - window.addEventListener('mouseup', () => game.registry.set('pan', false)); - window.addEventListener('mousedown', () => game.registry.set('pan', true)); - window.addEventListener('resize', () => { - game.scale.displaySize.maxWidth = window.innerHeight * 1.6; - game.scale.displaySize.maxHeight = window.innerHeight; - }); - - - return game; -} - -module.exports = renderCryps; diff --git a/phaser-client/src/scenes/elements/box.js b/phaser-client/src/scenes/elements/box.js deleted file mode 100644 index b95e6287..00000000 --- a/phaser-client/src/scenes/elements/box.js +++ /dev/null @@ -1,132 +0,0 @@ -const Phaser = require('phaser'); -const { TEXT } = require('.././constants'); - -const BOX = ` -#ifdef GL_ES -precision mediump float; -#endif - -#extension GL_OES_standard_derivatives : enable - -#ifdef GL_ES -precision mediump float; -#endif - -#extension GL_OES_standard_derivatives : enable - -uniform float time; -uniform vec2 resolution; -uniform vec2 dimensions; -uniform vec2 offset; -uniform vec3 colour; -uniform sampler2D uMainSampler; - - -varying vec2 outTexCoord; -varying vec4 outTint; - -float sdBox( in vec2 p, in vec2 b ) -{ - vec2 d = abs(p)-b; - return length(max(d,vec2(0))) + min(max(d.x,d.y),0.0); -} - -void main() -{ - - vec2 p = (gl_FragCoord.xy / resolution.xy); - p.x -= offset.x / resolution.x + dimensions.x / (2.0 * resolution.x); - p.y -= -1.0 * offset.y / resolution.y + ((resolution.y - dimensions.y) / (2.0 * resolution.y)) + 0.5; - vec2 dim = 0.5 * dimensions / resolution.xy; - float d = sdBox(p, dim); - float tb = abs(sin(time)) + 0.9; - - vec3 col = tb * colour - sign(d) * vec3(0.1); - col *= 0.0 + exp(-100.0 * abs(d)); - col += colour * 0.8; - vec4 texel = texture2D(uMainSampler, outTexCoord); - texel *= vec4(outTint.rgb * outTint.a, outTint.a); - - gl_FragColor = vec4(col, 1.0); -} -`; - - -class CustomPipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline { - constructor(game) { - super({ game, renderer: game.renderer, fragShader: BOX }); - } -} - -function rgbToHex(rgb) { - const getHex = (c) => { - const hex = Math.floor(c * 255).toString(16); - return hex.length === 1 ? `0${hex}` : hex; - }; - return `0x${getHex(rgb[0])}${getHex(rgb[1])}${getHex(rgb[2])}`; -} - - -class BoxEffect extends Phaser.GameObjects.Graphics { - constructor(scene, x, y, width, height, colour, tag) { - super(scene); - this.tag = tag; - this.customPipeline = scene.game.renderer.addPipeline(tag, new CustomPipeline(scene.game)); - this.customPipeline.setFloat2('resolution', 1600, 1000); - this.customPipeline.setFloat2('offset', x, y); - this.customPipeline.setFloat2('dimensions', width, height); - this.customPipeline.setFloat3('colour', colour[0], colour[1], colour[2]); - this.bgTime = 10.0; - - const radius = height / 2; - this.fillStyle(rgbToHex(colour), 1.0); - this.fillRect(x + radius, y, width - radius * 2, height); - this.fillCircle(x + radius, y + radius, radius); - this.fillCircle(x + width - radius, y + radius, radius); - - - this.on('destroy', () => { - scene.game.renderer.removePipeline(tag); - }); - } - - activate() { - this.setPipeline(this.tag); - } - - deactivate() { - this.resetPipeline(); - } - - update() { - this.bgTime += 0.05; - this.customPipeline.setFloat1('time', this.bgTime); - } -} - -class Button extends Phaser.GameObjects.Group { - constructor(scene, props) { - const { - x, y, width, height, colour, glTag, bText, callback, - } = props; - - super(scene, { classType: BoxEffect, runChildUpdate: true }); - - const leaveGame = scene.add - .rectangle(x, y, width, height, 0xaaaaaa, 0xffffff) - .setInteractive() - .setOrigin(0); - - const effect = scene.add.existing(new BoxEffect(scene, x, y, width, height, colour, glTag)); - this.add(effect); - - leaveGame - .on('pointerdown', callback) - .on('pointerover', () => effect.activate()) - .on('pointerout', () => effect.deactivate()); - - this.buttonText = scene.add.text(leaveGame.getCenter().x, leaveGame.getCenter().y, bText, TEXT.HEADER).setOrigin(0.5, 0.5); - } -} - -module.exports = Button; diff --git a/phaser-client/src/scenes/elements/combat.statbar.js b/phaser-client/src/scenes/elements/combat.statbar.js deleted file mode 100644 index 7189e945..00000000 --- a/phaser-client/src/scenes/elements/combat.statbar.js +++ /dev/null @@ -1,86 +0,0 @@ -const Phaser = require('phaser'); -const { TEXT, POSITIONS: { COMBAT }, COLOURS } = require('.././constants'); - -const CRYP_MARGIN = COMBAT.crypMargin(); -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; - 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; - return { statTextX, statTextY }; -}; - - -class StatBar extends Phaser.GameObjects.Graphics { - constructor(scene, cryp, type) { - super(scene); - this.crypObj = cryp; - this.type = type; - - if (type === 'HP') { - this.val = this.crypObj.cryp.hp.value; - this.max = this.crypObj.cryp.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.margin = 1; - } else if (type === 'Blue Shield') { - this.val = this.crypObj.cryp.blue_shield.value; - this.max = this.crypObj.cryp.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.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); - this.drawStatBar(); - } - - drawStatBar() { - this.clear(); - const { - statBarX, statBarY, statBarWidth, statBarHeight, - } = statBarDimensions(this.crypObj.team, this.crypObj.iter, this.margin); - this.statText.text = `${this.val.toString()} / ${this.max.toString()} ${this.type}`; - // Draw Black Border - this.fillStyle(COLOURS.BLACK); - this.fillRect(statBarX, statBarY, statBarWidth, statBarHeight); - // White fill - this.fillStyle(COLOURS.WHITE); - this.fillRect(statBarX + 2, statBarY + 2, statBarWidth - 4, statBarHeight - 4); - // Fill the health bar - const statPercentage = this.val / this.max; - if (statPercentage < 0.3) { - this.fillStyle(COLOURS.RED); - } else if (statPercentage < 0.65) { - this.fillStyle(COLOURS.YELLOW); - } else { - this.fillStyle(0x00ff00); // str8 up green - } - const statWidth = statBarWidth * statPercentage; - this.fillRect(statBarX + 2, statBarY + 2, statWidth, statBarHeight - 4); - } - - takeDamage(value) { - if (value > 0) { - this.val = (value >= this.val) ? 0 : this.val -= value; - } else { - this.val = (this.val - value > this.max) ? this.max : this.val -= value; - } - if (this.val === 0 && this.type === 'HP') this.crypObj.setKo(); - this.drawStatBar(); - } -} - -module.exports = StatBar; diff --git a/phaser-client/src/scenes/elements/item.js b/phaser-client/src/scenes/elements/item.js deleted file mode 100644 index 07e820b3..00000000 --- a/phaser-client/src/scenes/elements/item.js +++ /dev/null @@ -1,56 +0,0 @@ -const Phaser = require('phaser'); - -const { - TEXT, - COLOURS, -} = require('../constants'); - -function FindColour(item) { - // Future add skills and use a constants lookup file ?? - switch (item) { - case 'Green': return 0x396E26; - case 'Red': return 0x622433; - case 'Blue': return 0x223158; - // case 'Green': return 0x043003; - // case 'Red': return 0x5C0202; - // case 'Blue': return 0x040345; - - default: return 0x222222; - } -} - -class Item extends Phaser.GameObjects.Container { - constructor(scene, item, index, x, y, width, height) { - super(scene, x, y); - - this.scene = scene; - this.item = item; - this.index = index; - this.origX = x; - this.origY = y; - this.width = width; - this.height = height; - - this.colour = FindColour(item); - this.box = scene.add - .rectangle(0, 0, width, height, this.colour); - - this.text = scene.add - // .text(0, 0, `${action} x${count}`, TEXT.NORMAL) - .text(0, 0, `${item}`, TEXT.NORMAL) - .setOrigin(0.5, 0.5); - - this.add(this.box); - this.add(this.text); - - this.setSize(width, height); - this.setInteractive(); - } - - changeOrigin(x, y) { - this.origX = x + this.width / 2; - this.origY = y + this.height / 2; - } -} - -module.exports = Item; diff --git a/phaser-client/src/scenes/elements/outline.rotate.js b/phaser-client/src/scenes/elements/outline.rotate.js deleted file mode 100644 index 041611ee..00000000 --- a/phaser-client/src/scenes/elements/outline.rotate.js +++ /dev/null @@ -1,73 +0,0 @@ -const Phaser = require('phaser'); - -class LineBox extends Phaser.GameObjects.Graphics { - constructor(scene, x, y, width, height, colour, speed) { - super(scene); - this.colour = colour; - this.x0 = x; this.x1 = x + width; - this.y0 = y; this.y1 = y + height; - const margin = Math.abs(Math.floor((this.x1 - this.x0) / 4)); - this.lineCoord = [this.x0 + margin, this.x1 - margin, this.y0, this.y0, 0]; - this.speed = speed; - } - - update() { - this.clear(); - - let vertX = this.x1; - let horizY = this.y0; - const genLine = () => { - switch (this.lineCoord[4]) { - case 0: - if (this.lineCoord[1] < this.x1) return [1, 1, 0, 0, 0]; - return [0, 0, 0, 0, 1]; - case 1: - if (this.lineCoord[0] < this.x1) return [1, 0, 0, 1, 1]; - return [0, 0, 0, 0, 2]; - case 2: - if (this.lineCoord[3] < this.y1) return [0, 0, 1, 1, 2]; - return [0, 0, 0, 0, 3]; - case 3: - horizY = this.y1; - if (this.lineCoord[2] < this.y1) return [-1, 0, 1, 0, 3]; - return [0, 0, 0, 0, 4]; - case 4: - horizY = this.y1; - if (this.lineCoord[0] > this.x0) return [-1, -1, 0, 0, 4]; - return [0, 0, 0, 0, 5]; - case 5: - horizY = this.y1; - vertX = this.x0; - if (this.lineCoord[1] > this.x0) return [0, -1, -1, 0, 5]; - return [0, 0, 0, 0, 6]; - case 6: - vertX = this.x0; - if (this.lineCoord[2] >= this.y0) return [0, 0, -1, -1, 6]; - return [0, 0, 0, 0, 7]; - case 7: - vertX = this.x0; - if (this.lineCoord[3] >= this.y0) return [0, 1, 0, -1, 7]; - return [0, 0, 0, 0, 0]; - default: return false; - } - }; - for (let i = 0; i < this.speed; i += 1) { - const delta = genLine(); - this.lineCoord = this.lineCoord.map((x, j) => { - if (j < 4) return (x + delta[j]); - return delta[j]; - }); - } - this.lineStyle(5, this.colour, 1); - this.lineBetween(this.lineCoord[0], horizY, this.lineCoord[1], horizY); - this.lineBetween(vertX, this.lineCoord[2], vertX, this.lineCoord[3]); - } -} - -class LineGroup extends Phaser.GameObjects.Group { - constructor(scene) { - super(scene, { classType: LineBox, runChildUpdate: true }); - } -} - -module.exports = { LineGroup, LineBox } \ No newline at end of file diff --git a/phaser-client/src/scenes/game.list.js b/phaser-client/src/scenes/game.list.js deleted file mode 100644 index cdb16b06..00000000 --- a/phaser-client/src/scenes/game.list.js +++ /dev/null @@ -1,53 +0,0 @@ -const Phaser = require('phaser'); -const { TEXT, POSITIONS: { MENU_MAIN } } = require('./constants'); - -const X = MENU_MAIN.x(); -const Y = MENU_MAIN.y(); -const WIDTH = MENU_MAIN.width(); -const HEIGHT = MENU_MAIN.height(); -const ROW_SIZE = 50; -const LOBBY_WIDTH = WIDTH / 2; - -class GameList extends Phaser.Scene { - constructor() { - super({ key: 'GameList' }); - } - - create(gameList) { - this.cameras.main.setViewport(X, Y, WIDTH, HEIGHT); - const ws = this.registry.get('ws'); - - this.add.text(WIDTH / 3, 0, 'PVP open games', TEXT.HEADER); - const gameRow = (game, i) => { - const GAME_X = WIDTH / 6; - const GAME_Y = 1.3 * ROW_SIZE * (i + 1); - - const gameBox = this.add - .rectangle(GAME_X, GAME_Y, LOBBY_WIDTH, ROW_SIZE, 0x222222) - .setInteractive() - .setOrigin(0); - - const TITLE = `${game.teams[0].cryps.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); - ws.sendGameJoin(game.id, team); - }); - }; - - gameList.forEach(gameRow); - - return true; - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = GameList; diff --git a/phaser-client/src/scenes/header.js b/phaser-client/src/scenes/header.js deleted file mode 100644 index f2cd78e3..00000000 --- a/phaser-client/src/scenes/header.js +++ /dev/null @@ -1,27 +0,0 @@ -const Phaser = require('phaser'); -const fs = require('fs'); - -const { TEXT } = require('./constants'); - -const aztecAtlas = require('../../assets/aztec.atlas.json'); - - -class Header extends Phaser.Scene { - constructor() { - super({ key: 'Header', active: true }); - } - - preload() { - const aztecImg = new Image(); - aztecImg.src = `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/aztec.clean.png')).toString('base64')}`; - aztecImg.onload = () => { - this.textures.addAtlas('aztec', aztecImg, aztecAtlas); - }; - } - - create() { - this.add.text(0, 0, 'cryps.gg', TEXT.HEADER); - } -} - -module.exports = Header; diff --git a/phaser-client/src/scenes/home.cryps.js b/phaser-client/src/scenes/home.cryps.js deleted file mode 100644 index f112dba1..00000000 --- a/phaser-client/src/scenes/home.cryps.js +++ /dev/null @@ -1,142 +0,0 @@ -const Phaser = require('phaser'); -const { remove } = require('lodash'); - -const { TEXT, COLOURS, POSITIONS: { CRYP_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 menuY = CRYP_LIST.height() * 0.8; - -const KEY_MAP = [ - 'keydown-ONE', - 'keydown-TWO', - 'keydown-THREE', -]; - -const NULL_UUID = '00000000-0000-0000-0000-000000000000'; - -class HomeCrypList extends Phaser.Scene { - constructor() { - super({ key: 'HomeCryps' }); - } - - - updateData(parent, key, data) { - if (key === 'crypList') { - 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.registry.events.on('changedata', this.updateData, this); - this.registry.events.on('setdata', this.updateData, this); - const cryps = this.registry.get('crypList'); - const lineGroup = this.add.existing(new LineGroup(this)); - - if (!cryps) 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]; - 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 ACTIVE_FILL = 0.2; - - const FILL = Object.values(COLOURS)[i]; - // Selection of cryps - - // Cryp avatar and interaction box - const cReady = this.add - .rectangle(ROW_X, ROW_Y + ROW_HEIGHT * 0.2, BOX_WIDTH * 2, ROW_HEIGHT, FILL) - .setInteractive() - .setOrigin(0); - cReady.setAlpha(0.2); - cReady.on('pointerdown', () => { - lineGroup.clear(true, true); - if (this.activeCryps.includes(cReady)) { - remove(this.activeCryps, n => n === cReady); - cReady.setAlpha(0.2); - } else { - this.activeCryps.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) - )); - } - }); - - cReady.itemSelect = () => { - cReady.setFillStyle(COLOURS.SELECT); - }; - cReady.itemDeselect = () => { - cReady.setFillStyle(FILL, ACTIVE_FILL); - }; - - cReady.cryp = cryp; - this.add.image( - cReady.getCenter().x, - cReady.getCenter().y, - 'aztec', - genAvatar(cryp.name) - ); - this.add.text(ROW_X + BOX_WIDTH, ROW_Y, cryp.name, TEXT.HEADER) - .setOrigin(0.5, 0.5); - } - - // Add Spawn Cryp 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.add - .text(spawn.getCenter().x, spawn.getCenter().y, '+', TEXT.HEADER) - .setOrigin(0.5, 0.5); - - const joinNormal = this.add - .rectangle(ROW_WIDTH * 0.3, menuY, ROW_WIDTH * 0.4, ROW_HEIGHT * 0.5, 0x888888) - .setInteractive() - .setOrigin(0) - .on('pointerdown', () => { - const playerCryps = []; - this.activeCryps.forEach(obj => playerCryps.push(obj.cryp.id)); - ws.sendPlayerCrypsSet(NULL_UUID, playerCryps); - }); - this.add - .text(joinNormal.getCenter().x, joinNormal.getCenter().y, 'Join Normal', TEXT.HEADER) - .setOrigin(0.5, 0.5); - - const joinInstance = this.add - .rectangle(ROW_WIDTH * 0.8, menuY, ROW_WIDTH * 0.4, ROW_HEIGHT * 0.5, 0x888888) - .setInteractive() - .setOrigin(0) - .on('pointerdown', () => { - const playerCryps = []; - this.activeCryps.forEach(obj => playerCryps.push(obj.cryp.id)); - ws.sendInstanceJoin(playerCryps); - }); - this.add - .text(joinInstance.getCenter().x, joinInstance.getCenter().y, 'New Instance', TEXT.HEADER) - .setOrigin(0.5, 0.5); - - return this; - } - - cleanUp() { - KEY_MAP.forEach(k => this.input.keyboard.removeListener(k)); - this.registry.events.off('changedata', this.updateData, this); - this.registry.events.off('setdata', this.updateData, this); - this.scene.remove(); - } -} - -module.exports = HomeCrypList; diff --git a/phaser-client/src/scenes/home.instances.js b/phaser-client/src/scenes/home.instances.js deleted file mode 100644 index db4e6994..00000000 --- a/phaser-client/src/scenes/home.instances.js +++ /dev/null @@ -1,48 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants'); - -const X = HOME_MAIN.x(); -const Y = HOME_MAIN.y(); -const WIDTH = HOME_MAIN.width(); -const HEIGHT = HOME_MAIN.height(); - -const NULL_UUID = '00000000-0000-0000-0000-000000000000'; - -class HomeRankings extends Phaser.Scene { - constructor() { - super({ key: 'HomeInstances' }); - } - - create() { - this.add.text(X, Y, 'Instances Scene', TEXT.HEADER); - const playerList = this.registry.get('playerList'); - const addInstance = (player, i) => { - const joinNormal = this.add - .rectangle(X, Y + HEIGHT * 0.15 * (i + 1), WIDTH * 0.5, HEIGHT * 0.1, 0x888888) - .setInteractive() - .setOrigin(0) - .on('pointerdown', () => { - if (player.ready) { - this.registry.set('player', player); - this.registry.get('ws').sendInstanceReady(player.instance); - } else { - this.game.events.emit('SET_PLAYER', player); - this.registry.get('ws').sendInstanceScores(player.instance); - } - }); - const name = player.instance === NULL_UUID ? 'Normal Mode' : `${player.instance.substring(0, 5)}`; - const disp = player.ready ? name.concat(' - in progress') : name; - this.add - .text(joinNormal.getCenter().x, joinNormal.getCenter().y, disp, TEXT.NORMAL) - .setOrigin(0.5, 0.5); - }; - - playerList.forEach(addInstance); - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = HomeRankings; diff --git a/phaser-client/src/scenes/home.js b/phaser-client/src/scenes/home.js deleted file mode 100644 index 175fa4a4..00000000 --- a/phaser-client/src/scenes/home.js +++ /dev/null @@ -1,91 +0,0 @@ -const Phaser = require('phaser'); - - -const HomeCryps = require('./home.cryps'); -const HomeNavigation = require('./home.navigation'); - -const HomeRankings = require('./home.rankings'); -const HomeNews = require('./home.news'); -const HomeShop = require('./home.shop'); -const HomeInstances = require('./home.instances'); - -const FIXED_SCENES = [ - 'HomeCryps', - 'HomeNavigation', -]; - -const VAR_SCENES = [ - 'HomeRankings', - 'HomeNews', - 'HomeShop', - 'HomeInstances', -]; - -class Home extends Phaser.Scene { - constructor() { - super({ key: 'Home', active: true }); - } - - create() { - this.registry.get('ws').sendAccountInstances(); - - 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('HomeNavigation', HomeNavigation, true); - - - return true; - } - - updateData(parent, key, data) { - if (!data) return false; - // Controls which scene shows in the main top right section - switch (key) { - case 'game': return this.cleanUp(); - case 'menu': return this.cleanUp(); - case 'homeInstances': return this.newMainScene('HomeInstances', HomeInstances, data); - case 'homeRankings': return this.newMainScene('HomeRankings', HomeRankings, data); - case 'homeNews': return this.newMainScene('HomeNews', HomeNews, data); - case 'homeShop': return this.newMainScene('HomeShop', HomeShop, data); - - - default: return false; - } - } - - newMainScene(key, scene, data) { - let addScene = true; - // List of scenes which could be occupying the main section of the menu - VAR_SCENES.forEach((sKey) => { - if (this.scene.manager.keys[sKey]) { - if (key === sKey) { - // If there is new data for the current scene restart - this.scene.manager.keys[sKey].scene.restart(data); - addScene = false; - } else { - // Delete the old scene - this.scene.manager.keys[sKey].cleanUp(); - } - } - }); - if (addScene) this.scene.manager.add(key, scene, true, data); - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData, this); - this.registry.events.off('setdata', this.updateData, this); - // Delete scenes which could be showing before switching to battle scene - - const removeScenes = (sKey) => { - if (this.scene.get(sKey)) this.scene.get(sKey).cleanUp(); - }; - FIXED_SCENES.forEach(removeScenes); - VAR_SCENES.forEach(removeScenes); - - - this.scene.remove(); - } -} - -module.exports = Home; diff --git a/phaser-client/src/scenes/home.navigation.js b/phaser-client/src/scenes/home.navigation.js deleted file mode 100644 index 40846df8..00000000 --- a/phaser-client/src/scenes/home.navigation.js +++ /dev/null @@ -1,61 +0,0 @@ -const Phaser = require('phaser'); - -const { TEXT, POSITIONS: { NAVIGATION } } = require('./constants'); - -const X = NAVIGATION.x(); -const Y = NAVIGATION.y(); -const WIDTH = NAVIGATION.width(); -const HEIGHT = NAVIGATION.height(); - -const BTN_WIDTH = Math.floor(WIDTH / 6); -const BTN_HEIGHT = Math.floor(HEIGHT / 3); - -class HomeNavigation extends Phaser.Scene { - constructor() { - super({ key: 'HomeNavigation' }); - } - - create() { -/* const ranks = this.add - .rectangle(X, Y, BTN_WIDTH, BTN_HEIGHT, 0x222222) - .setInteractive() - .setOrigin(0); - this.add - .text(ranks.getCenter().x, ranks.getCenter().y, 'Rankings', TEXT.HEADER) - .setOrigin(0.5, 0.5); - ranks.on('pointerdown', () => this.registry.set('homeRankings', true)); - - const news = this.add - .rectangle(X + BTN_WIDTH * 1.5, Y, BTN_WIDTH, BTN_HEIGHT, 0x222222) - .setInteractive() - .setOrigin(0); - this.add - .text(news.getCenter().x, news.getCenter().y, 'News', TEXT.HEADER) - .setOrigin(0.5, 0.5); - news.on('pointerdown', () => this.registry.set('homeNews', true)); - - const shop = this.add - .rectangle(X + BTN_WIDTH * 3, Y, BTN_WIDTH, BTN_HEIGHT, 0x222222) - .setInteractive() - .setOrigin(0); - this.add - .text(shop.getCenter().x, shop.getCenter().y, 'Shop', TEXT.HEADER) - .setOrigin(0.5, 0.5); - shop.on('pointerdown', () => this.registry.set('homeShop', true)); - - const instances = this.add - .rectangle(X + BTN_WIDTH * 4.5, Y, BTN_WIDTH, BTN_HEIGHT, 0x222222) - .setInteractive() - .setOrigin(0); - this.add - .text(instances.getCenter().x, instances.getCenter().y, 'Instances', TEXT.HEADER) - .setOrigin(0.5, 0.5); - instances.on('pointerdown', () => this.registry.set('homeInstances', true));*/ - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = HomeNavigation; diff --git a/phaser-client/src/scenes/home.news.js b/phaser-client/src/scenes/home.news.js deleted file mode 100644 index 9e7937df..00000000 --- a/phaser-client/src/scenes/home.news.js +++ /dev/null @@ -1,24 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants'); - -const X = HOME_MAIN.x(); -const Y = HOME_MAIN.y(); -const WIDTH = HOME_MAIN.width(); -const HEIGHT = HOME_MAIN.height(); - -class HomeNews extends Phaser.Scene { - constructor() { - super({ key: 'HomeNews' }); - } - - create() { - this.add.text(X, Y, 'News Scene', TEXT.HEADER); - this.add.text(X, Y + HEIGHT * 0.1, 'some other stuff here', TEXT.NORMAL); - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = HomeNews; diff --git a/phaser-client/src/scenes/home.rankings.js b/phaser-client/src/scenes/home.rankings.js deleted file mode 100644 index 0d6dc0d1..00000000 --- a/phaser-client/src/scenes/home.rankings.js +++ /dev/null @@ -1,24 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants'); - -const X = HOME_MAIN.x(); -const Y = HOME_MAIN.y(); -const WIDTH = HOME_MAIN.width(); -const HEIGHT = HOME_MAIN.height(); - -class HomeRankings extends Phaser.Scene { - constructor() { - super({ key: 'HomeRankings' }); - } - - create() { - this.add.text(X, Y, 'Rankings Scene', TEXT.HEADER); - this.add.text(X, Y + HEIGHT * 0.1, 'some stuff here', TEXT.NORMAL); - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = HomeRankings; diff --git a/phaser-client/src/scenes/home.shop.js b/phaser-client/src/scenes/home.shop.js deleted file mode 100644 index 24ed0921..00000000 --- a/phaser-client/src/scenes/home.shop.js +++ /dev/null @@ -1,24 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants'); - -const X = HOME_MAIN.x(); -const Y = HOME_MAIN.y(); -const WIDTH = HOME_MAIN.width(); -const HEIGHT = HOME_MAIN.height(); - -class HomeShop extends Phaser.Scene { - constructor() { - super({ key: 'HomeShop' }); - } - - create() { - this.add.text(X, Y, 'Shop Scene', TEXT.HEADER); - this.add.text(X, Y + HEIGHT * 0.1, 'rulul', TEXT.NORMAL); - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = HomeShop; diff --git a/phaser-client/src/scenes/item.info.js b/phaser-client/src/scenes/item.info.js deleted file mode 100644 index 077e4c6e..00000000 --- a/phaser-client/src/scenes/item.info.js +++ /dev/null @@ -1,78 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { MENU_MAIN }, TEXT, ITEMS: { SKILLS, SPECS, COLOURS } } = require('./constants'); - -const X = MENU_MAIN.x(); -const Y = MENU_MAIN.y(); -const WIDTH = MENU_MAIN.width(); -const HEIGHT = MENU_MAIN.height(); - -const UNEQUIP_Y = Y + Math.floor(HEIGHT * 0.7); -const UNEQUIP_WIDTH = Math.floor(WIDTH * 0.4); -const UNEQUIP_HEIGHT = Math.floor(HEIGHT * 0.15); - -class ItemInfo extends Phaser.Scene { - constructor() { - super({ key: 'ItemInfo' }); - } - - create(props) { - const { item, cryp } = props; - if (!item) return false; - - // Default item text - let title = item; - let description = 'Description missing'; - let upgrades = ''; - let colours = ''; - - // Replace item text with constants if it exists - if (SKILLS[item]) { - title = `Skill Item - ${item}`; - ({ description } = SKILLS[item]); - if (SKILLS[item].upgrades) ({ upgrades } = SKILLS[item]); - if (SKILLS[item].colours) ({ colours } = SKILLS[item]); - } else if (SPECS[item]) { - title = `Spec Item - ${item}`; - ({ description } = SPECS[item]); - if (SPECS[item].upgrades) ({ upgrades } = SPECS[item]); - } else if (COLOURS[item]) { - title = `Colour Item - ${item}`; - ({ description } = COLOURS[item]); - if (COLOURS[item].upgrades) ({ upgrades } = COLOURS[item]); - } - - // Add text objects - this.add.text(X, Y, title, TEXT.HEADER); - this.add - .text(X, Y + HEIGHT * 0.1, description, TEXT.NORMAL) - .setWordWrapWidth(WIDTH * 0.75); - this.add - .text(X, Y + HEIGHT * 0.25, upgrades, TEXT.NORMAL) - .setWordWrapWidth(WIDTH * 0.75); - if (colours !== '') { - this.add - .text(X, Y + HEIGHT * 0.35, `Adds ${colours} to cryp`, TEXT.NORMAL) - .setWordWrapWidth(WIDTH * 0.75); - } - - if (!cryp) 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); - }); - this.add.text(unEquip.getCenter().x, unEquip.getCenter().y, 'unequip', TEXT.HEADER) - .setOrigin(0.5, 0.5); - return true; - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = ItemInfo; diff --git a/phaser-client/src/scenes/item.list.js b/phaser-client/src/scenes/item.list.js deleted file mode 100644 index c8d422b4..00000000 --- a/phaser-client/src/scenes/item.list.js +++ /dev/null @@ -1,323 +0,0 @@ -const Phaser = require('phaser'); - -const Item = require('./elements/item'); - -const { - TEXT, - POSITIONS: { ITEM_LIST }, -} = require('./constants'); - -const X = ITEM_LIST.x(); -const Y = ITEM_LIST.y(); -const WIDTH = ITEM_LIST.width(); -const HEIGHT = ITEM_LIST.height(); -const ITEM_WIDTH = ITEM_LIST.itemWidth(); -const ITEM_HEIGHT = ITEM_LIST.itemHeight(); - -const BOX_X = X + ITEM_WIDTH * 0.5; -const BOX_Y = Y + ITEM_HEIGHT + ITEM_HEIGHT * 2; -const BOX_ROWS = 6; -const BOX_COLUMNS = 3; - -const INV_X = X + ITEM_WIDTH * 0.5; -const INV_Y = Y + ITEM_HEIGHT * 12; -const INV_ROWS = 3; -const INV_COLUMNS = 3; - -const COMB_X = X + ITEM_WIDTH * 0.5; -const COMB_Y = Y + ITEM_HEIGHT * 19; -const COMB_ROWS = 1; -const COMB_COLUMNS = 3; - -const drawVbox = (graphics) => { - const boxDrawX = BOX_X - ITEM_WIDTH * 0.05; - const boxDrawY = BOX_Y - ITEM_HEIGHT * 0.05; - graphics.strokeRect(boxDrawX, boxDrawY, ITEM_WIDTH * 1.1 * BOX_COLUMNS, ITEM_HEIGHT * 1.1 * BOX_ROWS); - - for (let i = 0; i < (BOX_COLUMNS - 1); i += 1) { - const x = boxDrawX + (i + 1) * ITEM_WIDTH * 1.1; - graphics.lineBetween(x, boxDrawY, x, boxDrawY + ITEM_HEIGHT * 1.1 * BOX_ROWS); - } - for (let i = 0; i < (BOX_ROWS - 1); i += 1) { - const y = boxDrawY + (i + 1) * ITEM_HEIGHT * 1.1; - graphics.lineBetween(boxDrawX, y, boxDrawX + ITEM_WIDTH * 1.1 * BOX_COLUMNS, y); - } -}; - -const drawInventory = (graphics) => { - const invDrawX = INV_X - ITEM_WIDTH * 0.05; - const invDrawY = INV_Y - ITEM_HEIGHT * 0.05; - graphics.strokeRect(invDrawX, invDrawY, ITEM_WIDTH * 1.1 * INV_COLUMNS, ITEM_HEIGHT * 1.1 * INV_ROWS); - - for (let i = 0; i < (INV_COLUMNS - 1); i += 1) { - const x = invDrawX + (i + 1) * ITEM_WIDTH * 1.1; - graphics.lineBetween(x, invDrawY, x, invDrawY + ITEM_HEIGHT * 1.1 * INV_ROWS); - } - for (let i = 0; i < (INV_ROWS - 1); i += 1) { - const y = invDrawY + (i + 1) * ITEM_HEIGHT * 1.1; - graphics.lineBetween(invDrawX, y, invDrawX + ITEM_WIDTH * 1.1 * INV_COLUMNS, y); - } -}; - -const drawCombiner = (graphics) => { - const combDrawX = COMB_X - ITEM_WIDTH * 0.05; - const combDrawY = COMB_Y - ITEM_HEIGHT * 0.05; - graphics.strokeRect(combDrawX, combDrawY, ITEM_WIDTH * 1.1 * COMB_COLUMNS, ITEM_HEIGHT * 1.1 * COMB_ROWS); - - for (let i = 0; i < (COMB_COLUMNS - 1); i += 1) { - const x = combDrawX + (i + 1) * ITEM_WIDTH * 1.1; - graphics.lineBetween(x, combDrawY, x, combDrawY + ITEM_HEIGHT * 1.1 * COMB_ROWS); - } - for (let i = 0; i <= (COMB_ROWS - 1); i += 1) { - const y = combDrawY + (i + 1) * ITEM_HEIGHT * 1.1; - graphics.lineBetween(combDrawX, y, combDrawX + ITEM_WIDTH * 1.1 * COMB_COLUMNS, y); - } -}; - -class CombinerHitBox extends Phaser.GameObjects.Rectangle { - constructor(scene, x, y, i) { - super(scene, x, y, ITEM_WIDTH, ITEM_HEIGHT, 0x000000); - this.setOrigin(0); - this.x = x; - this.y = y; - this.slot = i; - this.item = false; - this.itemSelect = () => this.setFillStyle(0x222222); - this.itemDeselect = () => this.setFillStyle(0x000000); - } - - allocate(item) { - if (this.item) this.deallocate(); - item.setPosition(this.x + item.width / 2, this.y + item.height / 2); - this.item = item; - } - - deallocate() { - if (this.item) this.item.setPosition(this.item.origX, this.item.origY); - this.item = false; - } -} - -class DeleteHitBox extends Phaser.GameObjects.Rectangle { - constructor(scene, x, y) { - super(scene, x, y, ITEM_WIDTH * 3.4, ITEM_HEIGHT * 1.25, 0x444444); - this.setOrigin(0); - this.itemSelect = () => this.setFillStyle(0xff0000); - this.itemDeselect = () => this.setFillStyle(0x444444); - } -} - - -const itemCheckHitbox = (scene, pointer) => { - const { list } = scene.scene.get('MenuCrypList').children; - const hitboxes = list.filter(c => c.cryp) - .concat(scene.children.list.filter(c => c instanceof CombinerHitBox || c instanceof DeleteHitBox)); - - let found; - for (let i = 0; i < hitboxes.length; i += 1) { - if (Phaser.Geom.Rectangle.ContainsPoint(hitboxes[i].getBounds(), pointer.position)) { - found = hitboxes[i]; - } else { - hitboxes[i].itemDeselect(); - } - } - - return found; -}; - -class ItemList extends Phaser.Scene { - constructor() { - super({ key: 'ItemList', active: true }); - } - - updateData(parent, key, data) { - if (key === 'player' || key === 'scores') { - this.registry.events.off('changedata', this.updateData, this); - this.registry.events.off('setdata', this.updateData, this); - this.scene.restart(); - } - } - - create() { - const player = this.registry.get('player'); - const scores = this.registry.get('scores') || []; - if (!player) return false; - const { vbox } = player; - this.registry.events.on('changedata', this.updateData, this); - this.registry.events.on('setdata', this.updateData, this); - if (!vbox.bound) return false; - if (!this.combinerItems || vbox.bound.length < this.registry.get('boundLength')) { - this.combinerItems = [-1, -1, -1]; - } - this.registry.set('boundLength', vbox.bound.length); - const ws = this.registry.get('ws'); - - // Static Elements - const graphics = this.add.graphics(); - graphics.lineStyle(5, 0x808080, 1.0); - drawCombiner(graphics); - drawInventory(graphics); - drawVbox(graphics); - - this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 0.5, `vBox - ${vbox.bits}b`, TEXT.HEADER); - this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 11, 'inventory', TEXT.HEADER); - this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 18, 'iCombinator', TEXT.HEADER); - this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 23, `Wins: ${player.score.wins}`, TEXT.HEADER); - this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 24, `Losses: ${player.score.losses}`, TEXT.HEADER); - - const discard = this.add - .rectangle(X + ITEM_WIDTH * 0.4, Y + ITEM_HEIGHT * 1.5, ITEM_WIDTH * 3.4, ITEM_HEIGHT * 1.25, 0x444444) - .setInteractive() - .setOrigin(0) - .on('pointerdown', () => this.registry.get('ws').sendVboxDiscard(vbox.instance)); - this.add.text(discard.getCenter().x, discard.getCenter().y, 'discard - 5b', TEXT.HEADER) - .setOrigin(0.5, 0.5); - - const combine = this.add - .rectangle(X + ITEM_WIDTH * 0.4, Y + ITEM_HEIGHT * 20.25, ITEM_WIDTH * 3.4, ITEM_HEIGHT * 1.25, 0x444444) - .setInteractive() - .setOrigin(0) - .on('pointerdown', () => { - ws.sendVboxCombine(vbox.instance, this.combinerItems); - this.combinerItems = [-1, -1, -1]; - this.children.list.filter(obj => obj instanceof CombinerHitBox).forEach(cBox => cBox.deallocate()); - }); - this.add.text(combine.getCenter().x, combine.getCenter().y, 'combine', TEXT.HEADER) - .setOrigin(0.5, 0.5); - - for (let i = 0; i < 3; i += 1) { - const ITEM_X = ITEM_WIDTH * 1.1 * (i % COMB_COLUMNS) + COMB_X; - const ITEM_Y = ITEM_HEIGHT * 1.1 * Math.floor(i / COMB_COLUMNS) + COMB_Y; - this.add.existing(new CombinerHitBox(this, ITEM_X, ITEM_Y, i)); - } - const del = this.add.existing(new DeleteHitBox(this, X + ITEM_WIDTH * 0.4, Y + ITEM_HEIGHT * 15.5)); - this.add.text(del.getCenter().x, del.getCenter().y, 'drop', TEXT.HEADER) - .setOrigin(0.5, 0.5); - - // Generate Items - vbox.bound.forEach((item, i) => { - const ITEM_X = ITEM_WIDTH * 1.1 * (i % INV_COLUMNS) + INV_X + ITEM_WIDTH * 0.5; - const ITEM_Y = ITEM_HEIGHT * 1.1 * Math.floor(i / INV_COLUMNS) + INV_Y + ITEM_HEIGHT * 0.5; - const clickFn = () => this.registry.set('itemInfo', { item }); - const itemBox = new Item(this, item, i, ITEM_X, ITEM_Y, ITEM_WIDTH, ITEM_HEIGHT); - itemBox.on('pointerdown', clickFn); - - this.input.setDraggable(itemBox); - this.add.existing(itemBox); - }); - - vbox.free.forEach((type, i) => { - type.forEach((item, j) => { - const ITEM_X = ITEM_WIDTH * 1.1 * i + BOX_X + ITEM_WIDTH * 0.5; - const ITEM_Y = ITEM_HEIGHT * 1.1 * j + BOX_Y + ITEM_HEIGHT * 0.5; - const clickFn = () => { - this.registry.set('itemInfo', { item }); - ws.sendVboxAccept(vbox.instance, i, j); - }; - const itemBox = new Item(this, item, i, ITEM_X, ITEM_Y, ITEM_WIDTH, ITEM_HEIGHT); - itemBox.on('pointerdown', clickFn); - this.add.existing(itemBox); - }); - }); - - // Restore previous combiner item slots - this.combinerItems.forEach((index, i) => { - if (index === -1) return false; - const item = this.children.list.filter(obj => obj instanceof Item).find(it => it.index === index); - const hitBox = this.children.list.filter(obj => obj instanceof CombinerHitBox).find(hb => hb.slot === i); - if (item) hitBox.allocate(item); - return true; - }); - - // allocation functions - const allocate = (item, hitBox) => { - hitBox.allocate(item); - this.combinerItems[hitBox.slot] = item.index; - this.registry.set('combinerItems', this.combinerItems); - }; - - const deallocate = (item) => { - const clearIndex = this.combinerItems.indexOf(item.index); - if (clearIndex !== -1) { - this.children.list.filter(obj => obj instanceof CombinerHitBox) - .forEach((cBox) => { - if (cBox.item === item) cBox.deallocate(); - }); - this.combinerItems[clearIndex] = -1; - this.registry.set('combinerItems', this.combinerItems); - } - item.setPosition(item.origX, item.origY); - }; - - const findUnallocated = () => { - for (let i = 0; i <= 2; i += 1) { - if (this.combinerItems[i] === -1) { - return this.children.list.filter(obj => obj instanceof CombinerHitBox).find(hb => hb.slot === i); - } - } return false; - }; - - // this.add.text(ITEM_WIDTH * 11, ITEM_HEIGHT * 1.1, 'Scoreboard', TEXT.HEADER); - // scores.forEach(([name, score], i) => { - // const SCORE_X = ITEM_WIDTH * 11; - // const SCORE_Y = ITEM_HEIGHT * 1.1 * (i + 2); - // this.add.text(SCORE_X, SCORE_Y, `${score.wins} - ${score.losses} | ${name}`, TEXT.NORMAL); - // }); - - // Add Handlers - this.input.on('dragstart', (pointer, item) => { - if (!(item instanceof Item)) return false; - return true; - }); - - this.input.on('drag', (pointer, item, dragX, dragY) => { - if (!(item instanceof Item)) return false; - item.setPosition(dragX, dragY); - const hitBox = itemCheckHitbox(this, pointer); - if (hitBox) hitBox.itemSelect(); - return true; - }); - - this.input.on('dragend', (pointer, item) => { - if (!(item instanceof Item)) return false; - // Check first for hitbox interaction - const hitBox = itemCheckHitbox(this, pointer); - if (hitBox) { - // hitbox can only be the combinerhitbox, deletehitbox or cryp avatar - hitBox.itemDeselect(); - if (hitBox instanceof CombinerHitBox) { - if (hitBox.item === item) deallocate(item); - else allocate(item, hitBox); - } else if (hitBox instanceof DeleteHitBox) { - ws.sendVboxReclaim(vbox.instance, item.index); - } else { - ws.sendVboxApply(vbox.instance, hitBox.cryp.id, item.index); - deallocate(item); - } return true; - } - // If not interacting with hitbox and didn't move much try to allocate the item - if (Math.hypot(item.x - item.origX, item.y - item.origY) < Math.hypot(item.width, item.height)) { - // Check theres a free combiner slot - const cBox = findUnallocated(); - if (cBox) { - allocate(item, cBox); - return true; - } - } - // If the item hasn't been allocated above reset to natural location - // Check if item needs to be deallocated - // Scene will restart if there is vbox change - deallocate(item); - return true; - }); - return this; - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData, this); - this.registry.events.off('setdata', this.updateData, this); - this.scene.remove(); - } -} - -module.exports = ItemList; diff --git a/phaser-client/src/scenes/menu.cryps.list.js b/phaser-client/src/scenes/menu.cryps.list.js deleted file mode 100644 index a6e3c1ea..00000000 --- a/phaser-client/src/scenes/menu.cryps.list.js +++ /dev/null @@ -1,137 +0,0 @@ -const Phaser = require('phaser'); - -const { TEXT, COLOURS, POSITIONS: { CRYP_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 TEXT_MARGIN = 24; - -const KEY_MAP = [ - 'keydown-ONE', - 'keydown-TWO', - 'keydown-THREE', -]; - -class MenuCrypList extends Phaser.Scene { - constructor() { - super({ key: 'MenuCrypList' }); - } - - 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); - } - - updateData(parent, key, data) { - if (key === 'player') { - this.drawCryps(data.cryps); - } - } - - 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; - - - const ACTIVE_FILL = 0.2; - - const FILL = Object.values(COLOURS)[i]; - // Selection of cryps - const selectFn = () => { - this.registry.set('crypStats', cryp); - }; - - // Cryp interaction box for adding items - const crypInteract = 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); - }; - crypInteract.itemDeselect = () => { - crypInteract.setFillStyle(FILL, ACTIVE_FILL); - }; - crypInteract.cryp = cryp; - - // Cryp Avatar - const { name } = cryp; - const crypImage = this.add.image( - crypInteract.getCenter().x - crypInteract.width / 4, - crypInteract.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 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 { red, green, blue } = cryp.colours; - const CRYP_COLOURS = [ - ['R', red], - ['G', green], - ['B', blue], - ]; - CRYP_COLOURS.forEach(colourText); - - this.crypGroup.addMultiple([crypInteract, crypImage, crypInfoText]); - - const crypSkill = (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 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 }; - itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo)); - this.crypGroup.add(itemObj); - }; - cryp.skills.forEach(crypSkill); - - const crypSpec = (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 itemObj = new Item(this, spec, j, SKILL_X, SKILL_Y, SKILL_WIDTH, SKILL_HEIGHT); - itemObj.setInteractive(); - const itemInfo = { item: spec, cryp }; - itemObj.on('pointerdown', () => this.registry.set('itemInfo', itemInfo)); - this.add.existing(itemObj); - this.crypGroup.add(itemObj); - }; - cryp.specs.forEach(crypSpec); - }; - cryps.forEach(addCryp); - - return true; - } - - cleanUp() { - KEY_MAP.forEach(k => this.input.keyboard.removeListener(k)); - this.registry.events.off('changedata', this.updateData, this); - this.registry.events.off('setdata', this.updateData, this); - this.scene.remove(); - } -} - -module.exports = MenuCrypList; diff --git a/phaser-client/src/scenes/menu.js b/phaser-client/src/scenes/menu.js deleted file mode 100644 index 78e6d749..00000000 --- a/phaser-client/src/scenes/menu.js +++ /dev/null @@ -1,97 +0,0 @@ -const Phaser = require('phaser'); - -// Scenes constantly showing -const MenuCrypList = require('./menu.cryps.list'); -const MenuNavigation = require('./menu.navigation'); -const ItemList = require('./item.list'); -// Scenes which change depending on menu context -const Zones = require('./zones'); -const GameList = require('./game.list'); -const StatSheet = require('./statsheet'); -const ItemInfo = require('./item.info'); - -const FIXED_MENU_SCENES = [ - 'MenuCrypList', - 'MenuNavigation', - 'ItemList', -]; - -const MAIN_MENU_SCENES = [ - 'Zones', - 'GameList', - 'StatSheet', - 'ItemInfo', -]; - -class Menu extends Phaser.Scene { - constructor() { - super({ key: 'Menu', active: true }); - } - - create() { - this.registry.events.on('changedata', this.updateData, this); - this.registry.events.on('setdata', this.updateData, this); - - // Request the latest player state when we load the scene - const player = this.registry.get('player'); - 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('MenuNavigation', MenuNavigation, true); - this.scene.manager.add('ItemList', ItemList, true); - this.registry.set('inMenu', true); - - return true; - } - - updateData(parent, key, data) { - if (!data) return false; - // Controls which scene shows in the main top right section - switch (key) { - case 'game': return this.cleanUp(); - 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 'itemInfo': return this.newMainScene('ItemInfo', ItemInfo, data); - default: return false; - } - } - - newMainScene(key, scene, data) { - let addScene = true; - // List of scenes which could be occupying the main section of the menu - MAIN_MENU_SCENES.forEach((sKey) => { - if (this.scene.manager.keys[sKey]) { - if (key === sKey) { - // If there is new data for the current scene restart - this.scene.manager.keys[sKey].scene.restart(data); - addScene = false; - } else { - // Delete the old scene - this.scene.manager.keys[sKey].cleanUp(); - } - } - }); - if (addScene) this.scene.manager.add(key, scene, true, data); - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData, this); - this.registry.events.off('setdata', this.updateData, this); - // Delete scenes which could be showing before switching to battle scene - const removeScenes = (sKey) => { - if (this.scene.get(sKey)) this.scene.get(sKey).cleanUp(); - }; - FIXED_MENU_SCENES.forEach(removeScenes); - MAIN_MENU_SCENES.forEach(removeScenes); - this.registry.set('inMenu', false); - this.combinerItems = this.registry.set('combinerItems', null); - - - this.scene.remove(); - } -} - -module.exports = Menu; diff --git a/phaser-client/src/scenes/menu.navigation.js b/phaser-client/src/scenes/menu.navigation.js deleted file mode 100644 index b6f72656..00000000 --- a/phaser-client/src/scenes/menu.navigation.js +++ /dev/null @@ -1,50 +0,0 @@ -const Phaser = require('phaser'); - -const { TEXT, POSITIONS: { NAVIGATION } } = require('./constants'); - -const X = NAVIGATION.x(); -const Y = NAVIGATION.y(); -const WIDTH = NAVIGATION.width(); -const HEIGHT = NAVIGATION.height(); - -const BTN_WIDTH = Math.floor(WIDTH / 4); -const BTN_HEIGHT = Math.floor(HEIGHT / 2); - -class MenuNavigation extends Phaser.Scene { - constructor() { - super({ key: 'MenuNavigation' }); - } - - create() { - const ws = this.registry.get('ws'); - const player = this.registry.get('player'); - this.cameras.main.setViewport(X, Y, WIDTH, HEIGHT); - - const ready = this.add - .rectangle(BTN_WIDTH * 3, 0, BTN_WIDTH, BTN_HEIGHT, 0x222222) - .setInteractive() - .setOrigin(0); - this.add - .text(ready.getCenter().x, ready.getCenter().y, 'Ready', TEXT.HEADER) - .setOrigin(0.5, 0.5); - ready.on('pointerdown', () => { - ws.sendInstanceReady(player.instance); - }); - - const menu = this.add - .rectangle(BTN_WIDTH * 3, BTN_HEIGHT, BTN_WIDTH, BTN_HEIGHT, 0x440000) - .setInteractive() - .setOrigin(0) - .on('pointerdown', () => this.registry.set('home', true)); - - this.add - .text(menu.getCenter().x, menu.getCenter().y, 'Menu', TEXT.HEADER) - .setOrigin(0.5, 0.5); - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = MenuNavigation; diff --git a/phaser-client/src/scenes/statsheet.js b/phaser-client/src/scenes/statsheet.js deleted file mode 100644 index e7116f56..00000000 --- a/phaser-client/src/scenes/statsheet.js +++ /dev/null @@ -1,143 +0,0 @@ -const Phaser = require('phaser'); -const { POSITIONS: { MENU_MAIN }, TEXT, SKILLS } = require('./constants'); -const Item = require('./elements/item'); - -const X = MENU_MAIN.x(); -const Y = MENU_MAIN.y(); -const WIDTH = MENU_MAIN.width(); -const HEIGHT = MENU_MAIN.height(); -const TEXT_MARGIN = 24; - -const SKILL_WIDTH = Math.floor(WIDTH / 10); - - -class DeleteHitBox extends Phaser.GameObjects.Rectangle { - constructor(scene, x, y) { - super(scene, x, y, SKILL_WIDTH, SKILL_WIDTH, 0x222222); - this.setOrigin(0); - this.itemSelect = () => this.setFillStyle(0xff0000); - this.itemDeselect = () => this.setFillStyle(0x222222); - } -} - -const itemCheckHitbox = (scene, pointer) => { - const { list } = scene.scene.get('MenuCrypList').children; - const hitboxes = list.filter(c => c.cryp) - .concat(scene.children.list.filter(c => c instanceof DeleteHitBox)); - - let found; - for (let i = 0; i < hitboxes.length; i += 1) { - if (Phaser.Geom.Rectangle.ContainsPoint(hitboxes[i].getBounds(), pointer.position)) { - found = hitboxes[i]; - } else { - hitboxes[i].itemDeselect(); - } - } - - return found; -}; - -class StatSheet extends Phaser.Scene { - constructor() { - super({ key: 'StatSheet' }); - } - - - updateData(parent, key, data) { - if (key === 'player') { - console.log('grep'); - console.log(data); - const cryp = data.cryps.find(c => c.id === this.cryp.id); - this.scene.restart(cryp); - } - } - - create(cryp) { - this.registry.events.on('changedata', this.updateData, this); - // const ws = this.registry.get('ws'); - - const player = this.registry.get('player'); - if (!player) return false; - // const { vbox } = player; - - this.cryp = cryp; - - /* - const del = this.add.existing(new DeleteHitBox(this, X + WIDTH * 0.7, Y + HEIGHT * 0.6)); - this.add.text(del.getCenter().x, del.getCenter().y, 'unequip', TEXT.HEADER) - .setOrigin(0.5, 0.5); - */ - - this.add.text(X, Y, cryp.name, TEXT.HEADER); - - const crypStat = (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, - ]; - - CRYP_STATS.forEach(crypStat); - /* - const knownSkill = (skill, i) => { - const SKILL_X = X + WIDTH * 0.4 + WIDTH * 0.125 * i; - const SKILL_Y = Y + HEIGHT * 0.15; - const itemObj = new Item(this, skill.skill, i, SKILL_X, SKILL_Y, SKILL_WIDTH, Math.floor(SKILL_WIDTH / 2)); - // itemObj.on('pointerdown', () => ); - this.input.setDraggable(itemObj); - this.add.existing(itemObj); - }; - cryp.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); - const knownSpec = (spec, i) => { - const SKILL_X = X + WIDTH * 0.4 + WIDTH * 0.125 * i; - const SKILL_Y = Y + HEIGHT * 0.4; - const itemObj = new Item(this, spec, i, SKILL_X, SKILL_Y, SKILL_WIDTH, Math.floor(SKILL_WIDTH / 2)); - // itemObj.on('pointerdown', () => ); - this.input.setDraggable(itemObj); - this.add.existing(itemObj); - }; - cryp.specs.forEach(knownSpec); - - - this.input.on('drag', (pointer, item, dragX, dragY) => { - if (!(item instanceof Item)) return false; - item.setPosition(dragX, dragY); - const hitBox = itemCheckHitbox(this, pointer); - if (hitBox) hitBox.itemSelect(); - return true; - }); - - this.input.on('dragend', (pointer, item) => { - if (!(item instanceof Item)) return false; - item.setPosition(item.origX, item.origY); - const hitBox = itemCheckHitbox(this, pointer); - if (hitBox) { - hitBox.itemDeselect(); - // add socket function for unlearn here - ws.sendVboxUnequip(vbox.instance, cryp.id, item.item); - } - return true; - }); - */ - return this; - } - - cleanUp() { - this.registry.events.off('changedata', this.updateData, this); - this.scene.remove(); - } -} - -module.exports = StatSheet; diff --git a/phaser-client/src/scenes/zone.controls.js b/phaser-client/src/scenes/zone.controls.js deleted file mode 100644 index bdbd4b4c..00000000 --- a/phaser-client/src/scenes/zone.controls.js +++ /dev/null @@ -1,41 +0,0 @@ -const Phaser = require('phaser'); - -const { TEXT, POSITIONS: { MENU_MAIN } } = require('./constants'); - -const X = MENU_MAIN.x(); -const Y = MENU_MAIN.y(); -const WIDTH = MENU_MAIN.width(); -const HEIGHT = MENU_MAIN.height(); - -class ZoneControls extends Phaser.Scene { - constructor() { - super({ key: 'ZoneControls' }); - } - - create(zoneId) { - this.cameras.main.setViewport(X, Y, WIDTH, HEIGHT); - - const menu = this.add - .rectangle(Math.floor(WIDTH * 0.7), Math.floor(HEIGHT * 0.8), Math.floor(WIDTH * 0.2), Math.floor(HEIGHT * 0.2), 0x888888) - .setInteractive() - .setOrigin(0); - - this.add - .text(menu.getCenter().x, menu.getCenter().y, 'Clear', TEXT.HEADER) - .setOrigin(0.5, 0.5); - - menu.on('pointerdown', () => { - this.registry.get('ws').sendZoneClose(zoneId); - this.scene.get('Zones').cleanUp(); - }); - - - return true; - } - - cleanUp() { - this.scene.remove(); - } -} - -module.exports = ZoneControls; diff --git a/phaser-client/src/scenes/zone.node.js b/phaser-client/src/scenes/zone.node.js deleted file mode 100644 index cd81e4cd..00000000 --- a/phaser-client/src/scenes/zone.node.js +++ /dev/null @@ -1,31 +0,0 @@ -const Phaser = require('phaser'); - -class ZoneNode extends Phaser.GameObjects.Sprite { - constructor(scene, x, y, id, success, tag) { - super(scene, x, y); - this.setTexture('eye'); - this.scene = scene; - this.success = success; - // this.text = (text.indexOf(',') > -1) ? text.split(',') : text; - this.id = id; - this.setPosition(x, y); - - const nodeNoDigits = tag.replace(/[0-9]/g, ''); - switch (nodeNoDigits) { - case 'BOSS': - this.setScale(0.25); - break; - case 'MINIBOSS': - this.setScale(0.1); - break; - default: - this.setScale(0.05); - } - if (this.success) { - this.setTint(0xff0000); - } - this.text = tag; - } -} - -module.exports = ZoneNode; diff --git a/phaser-client/src/scenes/zones.js b/phaser-client/src/scenes/zones.js deleted file mode 100644 index 13596dfc..00000000 --- a/phaser-client/src/scenes/zones.js +++ /dev/null @@ -1,129 +0,0 @@ -const Phaser = require('phaser'); -const Node = require('./zone.node'); -const ZoneControls = require('./zone.controls'); -const { POSITIONS: { MENU_MAIN }, TEXT } = require('./constants'); - -const X = MENU_MAIN.x(); -const Y = MENU_MAIN.y(); -const WIDTH = MENU_MAIN.width(); -const HEIGHT = MENU_MAIN.height(); - - -// Mouse click hold to move, Q + E to zoom in and out -// Press 'A' to reset allocated passive nodes - -class Zones extends Phaser.Scene { - constructor() { - super({ key: 'Zones' }); - } - - preload() { - this.load.image('eye', 'https://labs.phaser.io/assets/particles/green-orb.png'); - } - - create(zone) { - if (!zone) return false; - if (!this.scene.get('ZoneControls')) this.scene.manager.add('ZoneControls', ZoneControls, true, zone.id); - this.graphics = this.add.graphics(); - this.cameras.main.setViewport(X, Y, WIDTH, HEIGHT); - this.addNodes(zone.graph.nodes); - this.drawEdges(zone.graph.edges); - this.addCameraControl(); - this.addEvents(zone.id); - return this; - } - - addNodes(nodeData) { - this.nodes = []; - nodeData.forEach((n, i) => { - this.nodes[i] = this.add.existing( - new Node(this, n.x * 50 + 200, n.y * 50 + 200, i, n.success, n.tag) - ).setInteractive(); - }); - } - - addCameraControl() { - this.controls = new Phaser.Cameras.Controls.SmoothedKeyControl({ - camera: this.cameras.main, - zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), - zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), - acceleration: 0.005, - drag: 0.0005, - maxSpeed: 0.001, - }); - } - - addEvents(zoneId) { - this.input.on('pointerover', (pointer, gameObjects) => { - if (gameObjects[0] instanceof Node) { - this.displayNodeText(gameObjects[0], pointer); - } - }); - this.input.on('pointerout', (pointer, gameObjects) => { - if (gameObjects[0] instanceof Node) { - this.nodeText.destroy(); - } - }); - this.input.on('pointerup', (pointer, gameObjects) => { - if (Math.abs(pointer.upX - pointer.downX) < 5 - && Math.abs(pointer.upY - pointer.downY) < 5) { - // 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); - if (gameObjects[0].success) return false; - this.registry.get('ws').sendZoneJoin(zoneId, gameObjects[0].id, team); - } - } - return true; - }); - this.input.on('pointermove', (pointer) => { - const zoomFactor = 2 / this.cameras.main.zoom; - if (this.registry.get('pan')) { - const points = pointer.getInterpolatedPosition(2); - this.cameras.main.scrollX -= zoomFactor * (points[1].x - points[0].x); - this.cameras.main.scrollY -= zoomFactor * (points[1].y - points[0].y); - } - }, this); - } - - drawEdges(edgeData) { - this.graphics.clear(); - edgeData.forEach((e) => { - const nodeA = this.nodes[e[0]]; - const nodeB = this.nodes[e[1]]; - if (nodeA.success && nodeB.success) { - this.graphics.lineStyle(10, 0xfff00f, 0.2); - } else { - this.graphics.lineStyle(2, 0xffffff, 0.2); - } - this.graphics.lineBetween(nodeA.x, nodeA.y, nodeB.x, nodeB.y); - return true; - }); - } - - displayNodeText(node, pointer) { - if (this.nodeText) this.nodeText.destroy(); - this.nodeText = this.add.text(node.x, node.y, node.text, TEXT.HOVER).setPadding(32); - this.nodeText.setAlpha(0.8); - this.nodeText.setOrigin(pointer.x >= WIDTH * 0.65 ? 1 : 0, - pointer.y >= HEIGHT * 0.25 ? 1 : 0); - this.nodeText.setWordWrapWidth(450); - this.nodeText.setScale(1 / this.cameras.main.zoom); - } - - camPan(bool) { - this.pan = bool; - } - - update(delta) { - this.controls.update(delta); - } - - cleanUp() { - if (this.scene.get('ZoneControls')) this.scene.get('ZoneControls').cleanUp(); - this.scene.remove(); - } -} - -module.exports = Zones; diff --git a/phaser-client/src/socket.js b/phaser-client/src/socket.js deleted file mode 100644 index df705042..00000000 --- a/phaser-client/src/socket.js +++ /dev/null @@ -1,335 +0,0 @@ -const toast = require('izitoast'); -const cbor = require('borc'); - - -const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://cryps.gg/ws' : 'ws://localhost:40000'; - -function errorToast(err) { - console.error(err); - return toast.error({ - title: 'BEEP BOOP', - message: err, - position: 'topRight', - }); -} - -function createSocket(events) { - let ws; - - // handle account auth within the socket itself - // https://www.christian-schneider.net/CrossSiteWebSocketHijacking.html - let account = null; - - // ------------- - // Outgoing - // ------------- - function send(msg) { - console.log('outgoing msg', msg); - msg.token = account && account.token; - ws.send(cbor.encode(msg)); - } - - function sendAccountLogin(name, password) { - send({ method: 'account_login', params: { name, password } }); - } - - function sendAccountCreate(name, password) { - send({ method: 'account_create', params: { name, password } }); - } - - function sendAccountDemo() { - send({ method: 'account_demo', params: {} }); - } - - function sendAccountCryps() { - send({ method: 'account_cryps', params: {} }); - } - - function sendAccountInstances() { - send({ method: 'account_instances', params: {} }); - } - - function sendAccountZone() { - send({ method: 'account_zone', params: {} }); - } - - function sendCrypSpawn(name) { - send({ method: 'cryp_spawn', params: { name } }); - } - - function sendCrypLearn(id, skill) { - send({ method: 'cryp_learn', params: { id, skill } }); - } - - function sendCrypForget(id, skill) { - send({ method: 'cryp_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 sendGamePvp(crypIds) { - send({ method: 'game_pvp', params: { cryp_ids: crypIds } }); - } - - function sendGameJoin(gameId, crypIds) { - send({ method: 'game_join', params: { game_id: gameId, cryp_ids: crypIds } }); - } - - function sendSpecForget(id, spec) { - send({ method: 'cryp_unspec', params: { id, spec } }); - } - - function sendPlayerCrypsSet(instanceId, crypIds) { - send({ method: 'player_cryps_set', params: { instance_id: instanceId, cryp_ids: crypIds } }); - } - - function sendPlayerState(instanceId) { - send({ method: 'player_state', params: { instance_id: instanceId } }); - } - - function sendVboxAccept(instanceId, group, index) { - 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 sendVboxUnequip(instanceId, crypId, target) { - send({ method: 'player_vbox_unequip', params: { instance_id: instanceId, cryp_id: crypId, target } }); - } - - function sendVboxDiscard(instanceId) { - send({ method: 'player_vbox_discard', params: { instance_id: instanceId } }); - } - - function sendVboxCombine(instanceId, indices) { - send({ method: 'player_vbox_combine', params: { instance_id: instanceId, indices } }); - } - - function sendVboxReclaim(instanceId, index) { - send({ method: 'player_vbox_reclaim', params: { instance_id: instanceId, index } }); - } - - function sendGameSkill(gameId, crypId, targetCrypId, skill) { - send({ - method: 'game_skill', - params: { - game_id: gameId, cryp_id: crypId, target_cryp_id: targetCrypId, skill, - }, - }); - events.setActiveSkill(null); - } - - function sendGameTarget(gameId, crypId, skillId) { - send({ method: 'game_target', params: { game_id: gameId, cryp_id: crypId, skill_id: skillId } }); - events.setActiveSkill(null); - } - - function sendZoneCreate() { - 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 sendZoneClose(zoneId) { - send({ method: 'zone_close', params: { zone_id: zoneId } }); - } - - function sendInstanceJoin(cryps) { - send({ method: 'instance_join', params: { cryp_ids: cryps, pve: true } }); - } - - function sendInstanceReady(instanceId) { - send({ method: 'instance_ready', params: { instance_id: instanceId } }); - } - - function sendInstanceScores(instanceId) { - send({ method: 'instance_scores', params: { instance_id: instanceId } }); - } - - - // ------------- - // Incoming - // ------------- - function accountLogin(res) { - const [struct, login] = res; - - account = login; - events.setAccount(login); - sendAccountCryps(); - } - - function accountInstanceList(res) { - const [struct, instanceList] = res; - events.setInstanceList(instanceList); - } - - function accountCryps(response) { - const [structName, cryps] = response; - events.setCrypList(cryps); - } - - function gameState(response) { - const [structName, game] = response; - events.setGame(game); - } - - function crypSpawn(response) { - const [structName, cryp] = response; - } - - function gamePve(response) { - const [structName, game] = response; - } - - function zoneState(response) { - const [structName, zone] = response; - events.setZone(zone); - } - - function playerState(response) { - const [structName, player] = response; - events.setPlayer(player); - } - - function instanceScores(response) { - const [structName, scores] = response; - events.setScores(scores); - } - - // ------------- - // Setup - // ------------- - - // 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, - game_pve: gamePve, - game_state: gameState, - account_login: accountLogin, - account_create: accountLogin, - account_cryps: accountCryps, - account_instances: accountInstanceList, - instance_scores: instanceScores, - zone_create: res => console.log(res), - zone_state: zoneState, - zone_close: res => console.log(res), - player_state: playerState, - }; - - function errHandler(error) { - switch (error) { - case 'no active zone': return sendZoneCreate(); - case 'no cryps selected': return events.errorPrompt('select_cryps'); - case 'node requirements not met': return events.errorPrompt('complete_nodes'); - case 'cryp at max skills (4)': return events.errorPrompt('max_skills'); - - default: return errorToast(error); - - } - } - - // decodes the cbor and - // calls the handlers defined above based on message type - function onMessage(event) { - // decode binary msg from server - const blob = new Uint8Array(event.data); - const res = cbor.decode(blob); - const { method, params } = res; - - console.log(res); - - // check for error and split into response type and data - if (res.err) return errHandler(res.err); - if (!handlers[method]) return errorToast(`${method} handler missing`); - return handlers[method](params); - } - - function connect() { - ws = new WebSocket(SOCKET_URL); - ws.binaryType = 'arraybuffer'; - - // Connection opened - ws.addEventListener('open', () => { - toast.info({ - message: 'connected', - position: 'topRight', - }); - - if (!account) events.loginPrompt(); - if (process.env.NODE_ENV !== 'production') { - // send({ method: 'account_login', params: { name: 'ntr', password: 'grepgrepgrep' } }); - } - - return true; - }); - - // Listen for messages - ws.addEventListener('message', onMessage); - - ws.addEventListener('error', (event) => { - console.error('WebSocket error', event); - // account = null; - // return setTimeout(connect, 5000); - }); - - ws.addEventListener('close', (event) => { - console.error('WebSocket closed', event); - toast.warning({ - message: 'disconnected', - position: 'topRight', - }); - return setTimeout(connect, 5000); - }); - - return ws; - } - - return { - sendAccountLogin, - sendAccountCreate, - sendAccountDemo, - sendAccountCryps, - sendAccountInstances, - sendAccountZone, - sendGameState, - sendGamePve, - sendGamePvp, - sendGameJoin, - sendGameSkill, - sendGameTarget, - sendCrypSpawn, - sendCrypLearn, - sendCrypForget, - sendSpecForget, - sendZoneCreate, - sendZoneJoin, - sendZoneClose, - sendInstanceJoin, - sendInstanceReady, - sendInstanceScores, - sendPlayerCrypsSet, - sendPlayerState, - sendVboxAccept, - sendVboxApply, - sendVboxReclaim, - sendVboxCombine, - sendVboxDiscard, - sendVboxUnequip, - connect, - }; -} - -module.exports = createSocket; diff --git a/phaser-client/src/tutorial.js b/phaser-client/src/tutorial.js deleted file mode 100644 index a73ff00d..00000000 --- a/phaser-client/src/tutorial.js +++ /dev/null @@ -1,135 +0,0 @@ -const toast = require('izitoast'); - -const OK_BUTTON = ''; -const NO_MORE_BUTTON = ''; - -function noMore(instance, thisToast) { - window.localStorage.setItem('tutorial', 'none'); - return instance.hide({ transitionOut: 'fadeOut' }, thisToast); -} - -const WELCOME_MESSAGE = ` -Welcome to cryps.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. -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. -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. -`; - -// 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. -// It's wise to spread the damage around! -// `; - -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 -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 -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! -`; - -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. -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. -glhf! -`; - -const STEPS = [ - 'init', - 'welcome', - 'homepage', - 'skillPhase', - // 'targetPhase', - 'resolutionPhase', - 'finishPhase', - 'none', -]; - -function showTutorial(message, step, nextStep) { - const existing = document.querySelector(`#${step}`); // Selector of your toast - - if (existing) return false; - - toast.info({ - id: step, - theme: 'dark', - color: 'black', - timeout: false, - drag: false, - title: 'TUTORIAL', - position: 'bottomCenter', - maxWidth: window.innerWidth / 2, - close: false, - buttons: [ - [NO_MORE_BUTTON, noMore], - [OK_BUTTON, (instance, thisToast) => { - const thisStep = STEPS.indexOf(step); - const storageStep = STEPS.indexOf(window.localStorage.getItem('tutorial')); - if (thisStep >= storageStep) { - window.localStorage.setItem('tutorial', nextStep); - } - - return instance.hide({ transitionOut: 'fadeOut' }, thisToast); - }], - ], - message, - }); - - return true; -} - -function tutorial() { - function show(step) { - const currentStage = window.localStorage.getItem('tutorial'); - if (currentStage === 'none') { - return false; - } - - const thisStep = STEPS.indexOf(step); - const storageStep = STEPS.indexOf(window.localStorage.getItem('tutorial')); - - if (thisStep < storageStep) return false; - - if (step === 'welcome') return showTutorial(WELCOME_MESSAGE, 'welcome', 'homepage'); - if (step === 'homepage') return showTutorial(HOMEPAGE_MESSAGE, 'homepage', 'skillPhase'); - if (step === 'skillPhase') return showTutorial(SKILL_PHASE_MESSAGE, 'skillPhase', 'targetPhase'); - // if (step === 'targetPhase') return showTutorial(TARGET_PHASE_MESSAGE, 'targetPhase', 'resolutionPhase'); - if (step === 'resolutionPhase') return showTutorial(RESOLUTION_PHASE_MESSAGE, 'resolutionPhase', 'finishPhase'); - if (step === 'finishPhase') return showTutorial(FINISH_PHASE_MESSAGE, 'finishPhase', 'none'); - - return true; - } - - if (window.localStorage.getItem('tutorial') !== 'none') window.localStorage.setItem('tutorial', 'init'); - - return show; -} - -module.exports = tutorial; diff --git a/phaser-client/src/utils.js b/phaser-client/src/utils.js deleted file mode 100644 index e48b03ef..00000000 --- a/phaser-client/src/utils.js +++ /dev/null @@ -1,36 +0,0 @@ -const get = require('lodash/get'); - -const stringSort = (k, desc) => { - if (desc) { - return (a, b) => { - if (!get(a, k)) return 1; - if (!get(b, k)) return -1; - return get(b, k).localeCompare(get(a, k)); - }; - } - return (a, b) => { - if (!get(a, k)) return 1; - if (!get(b, k)) return -1; - return get(a, k).localeCompare(get(b, k)); - }; -}; - -const numSort = (k, desc) => { - if (desc) { - return (a, b) => { - if (!get(a, k)) return 1; - if (!get(b, k)) return -1; - return get(b, k) - get(a, k); - }; - } - return (a, b) => { - if (!get(a, k)) return 1; - if (!get(b, k)) return -1; - return get(a, k) - get(b, k); - }; -}; - -module.exports = { - stringSort, - numSort, -}; diff --git a/server/.env b/server/.env index f42f5c28..c5e1d4fe 100644 --- a/server/.env +++ b/server/.env @@ -1 +1 @@ -DATABASE_URL=postgres://cryps:craftbeer@localhost/cryps +DATABASE_URL=postgres://mnml:craftbeer@localhost/mnml diff --git a/server/Cargo.toml b/server/Cargo.toml index a0ed55f2..d6c4618b 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cryps" +name = "mnml" version = "0.1.0" authors = ["ntr "] diff --git a/server/src/account.rs b/server/src/account.rs index 6eb9b1a1..1b52d537 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -9,13 +9,13 @@ 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; use failure::err_msg; -static PASSWORD_MIN_LEN: usize = 12; +static PASSWORD_MIN_LEN: usize = 11; #[derive(Debug,Clone,Serialize,Deserialize)] pub struct Account { @@ -65,6 +65,10 @@ pub fn account_create(params: AccountCreateParams, tx: &mut Transaction) -> Resu return Err(err_msg("password must be at least 12 characters")); } + if params.password != "grepgrepgrep" { + return Err(err_msg("https://discord.gg/YJJgurM")); + } + if params.name.len() == 0 { return Err(err_msg("account name not supplied")); } @@ -151,34 +155,35 @@ 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() { + warn!("{:?}", constructs); + return Err(err_msg("could not deserialise 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/construct.rs similarity index 70% rename from server/src/cryp.rs rename to server/src/construct.rs index d5aec520..7465b037 100644 --- a/server/src/cryp.rs +++ b/server/src/construct.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(), @@ -70,24 +70,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 } @@ -108,11 +108,11 @@ pub enum Stat { Int, GreenLife, Speed, - RedDamage, + RedPower, + BluePower, + GreenPower, RedDamageTaken, - BlueDamage, BlueDamageTaken, - GreenDamage, GreenDamageTaken, RedLife, BlueLife, @@ -120,20 +120,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)) @@ -142,19 +142,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 @@ -163,7 +163,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; @@ -173,45 +173,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_power: ConstructStat, + pub red_life: ConstructStat, + pub blue_life: ConstructStat, + pub blue_power: ConstructStat, + pub green_power: 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_power: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::RedPower }, + red_life: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::RedLife }, + blue_power: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::BluePower }, + blue_life: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::BlueLife }, + green_power: ConstructStat { base: 256, value: 256, max: 256, stat: Stat::GreenPower }, + 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![], @@ -220,28 +220,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); @@ -251,7 +251,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")); } @@ -260,7 +260,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")), @@ -269,21 +269,21 @@ 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); + self.red_power.recalculate(&self.specs, &self.colours, player_colours); self.red_life.recalculate(&self.specs, &self.colours, player_colours); - self.blue_damage.recalculate(&self.specs, &self.colours, player_colours); + self.blue_power.recalculate(&self.specs, &self.colours, player_colours); self.blue_life.recalculate(&self.specs, &self.colours, player_colours); self.evasion.recalculate(&self.specs, &self.colours, player_colours); self.speed.recalculate(&self.specs, &self.colours, player_colours); - self.green_damage.recalculate(&self.specs, &self.colours, player_colours); + self.green_power.recalculate(&self.specs, &self.colours, player_colours); self.green_life.recalculate(&self.specs, &self.colours, player_colours); self @@ -293,7 +293,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 } @@ -341,7 +341,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()) @@ -378,19 +378,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() { @@ -413,7 +413,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); @@ -423,43 +423,43 @@ impl Cryp { // info!("reduced effect {:?}", effect); return Some(effect); - }).collect::>(); + }).collect::>(); self } // Stats - pub fn red_damage(&self) -> u64 { - let red_damage_mods = self.effects.iter() - .filter(|e| e.effect.modifications().contains(&Stat::RedDamage)) + pub fn red_power(&self) -> u64 { + let red_power_mods = self.effects.iter() + .filter(|e| e.effect.modifications().contains(&Stat::RedPower)) .map(|e| (e.effect, e.meta)) .collect::)>>(); - let modified_red_damage = red_damage_mods.iter() - .fold(self.red_damage.value, |acc, fx| fx.0.apply(acc, fx.1)); - return modified_red_damage; + let modified_red_power = red_power_mods.iter() + .fold(self.red_power.value, |acc, fx| fx.0.apply(acc, fx.1)); + return modified_red_power; } - pub fn blue_damage(&self) -> u64 { - let blue_damage_mods = self.effects.iter() - .filter(|e| e.effect.modifications().contains(&Stat::BlueDamage)) + pub fn blue_power(&self) -> u64 { + let blue_power_mods = self.effects.iter() + .filter(|e| e.effect.modifications().contains(&Stat::BluePower)) .map(|e| (e.effect, e.meta)) .collect::)>>(); - let modified_blue_damage = blue_damage_mods.iter() - .fold(self.blue_damage.value, |acc, fx| fx.0.apply(acc, fx.1)); - return modified_blue_damage; + let modified_blue_power = blue_power_mods.iter() + .fold(self.blue_power.value, |acc, fx| fx.0.apply(acc, fx.1)); + return modified_blue_power; } - pub fn green_damage(&self) -> u64 { - let green_damage_mods = self.effects.iter() - .filter(|e| e.effect.modifications().contains(&Stat::GreenDamage)) + pub fn green_power(&self) -> u64 { + let green_power_mods = self.effects.iter() + .filter(|e| e.effect.modifications().contains(&Stat::GreenPower)) .map(|e| (e.effect, e.meta)) .collect::)>>(); - let modified_green_damage = green_damage_mods.iter() - .fold(self.green_damage.value, |acc, fx| fx.0.apply(acc, fx.1)); - return modified_green_damage; + let modified_green_power = green_power_mods.iter() + .fold(self.green_power.value, |acc, fx| fx.0.apply(acc, fx.1)); + return modified_green_power; } pub fn skill_speed(&self, s: Skill) -> u64 { @@ -539,17 +539,17 @@ impl Cryp { .map(|e| (e.effect, e.meta)) .collect::)>>(); - let modified_damage = mods.iter() + let modified_power = mods.iter() .fold(amount, |acc, fx| fx.0.apply(acc, fx.1)); match self.affected(Effect::Invert) { false => { let current_green_life = self.green_life(); - self.green_life.increase(modified_damage); + self.green_life.increase(modified_power); let new_green_life = self.green_life.value; let healing = new_green_life - current_green_life; - let overhealing = modified_damage - healing; + let overhealing = modified_power - healing; events.push(Event::Healing { skill, @@ -562,7 +562,7 @@ impl Cryp { // there is no green shield (yet) let current_green_life = self.green_life(); - self.reduce_green_life(modified_damage); + self.reduce_green_life(modified_power); let delta = current_green_life - self.green_life(); events.push(Event::Damage { @@ -598,7 +598,7 @@ impl Cryp { .map(|e| (e.effect, e.meta)) .collect::)>>(); - let modified_damage = mods.iter() + let modified_power = mods.iter() .fold(amount, |acc, fx| fx.0.apply(acc, fx.1)); match self.affected(Effect::Invert) { @@ -607,8 +607,8 @@ impl Cryp { // eg 50 red_life 25 damage -> 0 remainder 25 mitigation // 50 red_life 100 damage -> 50 remainder 50 mitigation // 50 red_life 5 damage -> 0 remainder 5 mitigation - let remainder = modified_damage.saturating_sub(self.red_life.value); - let mitigation = modified_damage.saturating_sub(remainder); + let remainder = modified_power.saturating_sub(self.red_life.value); + let mitigation = modified_power.saturating_sub(remainder); // reduce red_life by mitigation amount self.red_life.reduce(mitigation); @@ -629,10 +629,10 @@ impl Cryp { events.push(Event::Inversion { skill }); let current_green_life = self.green_life(); - self.green_life.increase(modified_damage); + self.green_life.increase(modified_power); let new_green_life = self.green_life.value; let healing = new_green_life - current_green_life; - let overhealing = modified_damage - healing; + let overhealing = modified_power - healing; let current_life = self.red_life.value; self.red_life.increase(overhealing); @@ -677,13 +677,13 @@ impl Cryp { .map(|e| (e.effect, e.meta)) .collect::)>>(); - let modified_damage = mods.iter() + let modified_power = mods.iter() .fold(amount, |acc, fx| fx.0.apply(acc, fx.1)); match self.affected(Effect::Invert) { false => { - let remainder = modified_damage.saturating_sub(self.blue_life.value); - let mitigation = modified_damage.saturating_sub(remainder); + let remainder = modified_power.saturating_sub(self.blue_life.value); + let mitigation = modified_power.saturating_sub(remainder); // reduce blue_life by mitigation amount self.blue_life.reduce(mitigation); @@ -704,10 +704,10 @@ impl Cryp { events.push(Event::Inversion { skill }); let current_green_life = self.green_life(); - self.green_life.increase(modified_damage); + self.green_life.increase(modified_power); let new_green_life = self.green_life.value; let healing = new_green_life - current_green_life; - let overhealing = modified_damage - healing; + let overhealing = modified_power - healing; let current_life = self.blue_life.value; self.blue_life.increase(overhealing); @@ -735,7 +735,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, @@ -777,10 +777,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; "; @@ -788,110 +788,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::StrikeI); - 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::StrikeI); + construct.spec_add(Spec::GreenLifeI).unwrap(); + construct.spec_add(Spec::RedPowerI).unwrap(); + construct.spec_add(Spec::RedPowerI).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::RedPowerI).unwrap(); + construct.spec_add(Spec::GreenPowerI).unwrap(); + construct.spec_add(Spec::BluePowerI).unwrap(); let player_colours = Colours { red: 5, @@ -899,11 +899,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_power.value == construct.red_power.base + construct.red_power.base.pct(20)); + assert!(construct.green_power.value == construct.green_power.base + construct.green_power.base.pct(40)); + assert!(construct.blue_power.value == construct.blue_power.base + construct.blue_power.base.pct(80)); return; } diff --git a/server/src/game.rs b/server/src/game.rs index c57fceb5..74a0a99a 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_power.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::RiposteI.multiplier()))); + assert_eq!(game.player_by_id(y_player.id).unwrap().constructs[0].green_life(), (1024 - x_construct.red_power().pct(Skill::RiposteI.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::ScatterI); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::ScatterI); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::ScatterI).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::ScatterI).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::ScatterI).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::ScatterI).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::RuinI); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::RuinI); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::RuinI).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::RuinI).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::RuinI).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::RuinI).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::TauntI); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::TauntI); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::TauntI).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::TauntI).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::TauntI).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::TauntI).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::DecayI); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::DecayI).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::DecayI); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::DecayI).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.cryp_by_id(x_cryp.id).unwrap().learn_mut(Skill::SiphonI); - while game.cryp_by_id(x_cryp.id).unwrap().skill_on_cd(Skill::SiphonI).is_some() { - game.cryp_by_id(x_cryp.id).unwrap().reduce_cooldowns(); + game.construct_by_id(x_construct.id).unwrap().learn_mut(Skill::SiphonI); + while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::SiphonI).is_some() { + game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.cryp_by_id(y_cryp.id).unwrap().learn_mut(Skill::PurifyI); - while game.cryp_by_id(y_cryp.id).unwrap().skill_on_cd(Skill::PurifyI).is_some() { - game.cryp_by_id(y_cryp.id).unwrap().reduce_cooldowns(); + game.construct_by_id(y_construct.id).unwrap().learn_mut(Skill::PurifyI); + while game.construct_by_id(y_construct.id).unwrap().skill_on_cd(Skill::PurifyI).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::DecayI).unwrap(); + game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::DecayI).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::PurifyI).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::PurifyI).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::SiphonI).unwrap(); + game.add_skill(y_player.id, x_construct.id, Some(y_construct.id), Skill::SiphonI).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::PurifyI).unwrap(); + game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::PurifyI).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 43fc6fae..07b48bc1 100644 --- a/server/src/item.rs +++ b/server/src/item.rs @@ -1,6 +1,6 @@ use skill::{Skill, Colour}; use spec::{Spec}; -use cryp::{Colours}; +use construct::{Colours}; #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] pub enum Item { @@ -18,7 +18,7 @@ pub enum Item { // specs // Base - Damage, + Power, Life, Speed, @@ -30,10 +30,10 @@ pub enum Item { GBLI, RBLI, - // Damage Upgrades - RedDamageI, - BlueDamageI, - GreenDamageI, + // Power Upgrades + RedPowerI, + BluePowerI, + GreenPowerI, GRDI, GBDI, RBDI, @@ -188,7 +188,7 @@ impl Item { Item::Debuff => 2, Item::Stun => 2, - Item::Damage => 3, + Item::Power => 3, Item::Life => 3, Item::Speed => 3, @@ -338,10 +338,10 @@ impl Item { Item::GBSpeedI => Some(Spec::GBSpeedI), Item::RBSpeedI => Some(Spec::RBSpeedI), - Item::Damage => Some(Spec::Damage), - Item::RedDamageI => Some(Spec::RedDamageI), - Item::BlueDamageI => Some(Spec::BlueDamageI), - Item::GreenDamageI => Some(Spec::GreenDamageI), + Item::Power => Some(Spec::Power), + Item::RedPowerI => Some(Spec::RedPowerI), + Item::BluePowerI => Some(Spec::BluePowerI), + Item::GreenPowerI => Some(Spec::GreenPowerI), Item::GRDI => Some(Spec::GRDI), Item::GBDI => Some(Spec::GBDI), Item::RBDI => Some(Spec::RBDI), @@ -375,52 +375,52 @@ impl Item { Item::Red => format!("Combine with skills and specs to create upgraded items. \n Speed and chaos."), // base skills - Item::Attack => format!("Deal red damage based on {:?}% red power", + Item::Attack => format!("Deal RedDamage based on {:?}% RedPower", self.into_skill().unwrap().multiplier()), - Item::Block => format!("Reduce incoming red damage by {:?}%", + Item::Block => format!("Reduce incoming RedDamage by {:?}%", 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 RedPower 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::Power => format!("Base ITEM for increased Power. Power determines the damage caused by 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. + RedDamage dealt to your construct reduces RedLife before GreenLife."), + Item::BlueLifeI => format!("Increases CONSTRUCT BlueLife. + BlueDamage 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."), + // Power Upgrades + Item::RedPowerI => format!("Increases CONSTRUCT RedPower."), + Item::BluePowerI => format!("Increases CONSTRUCT BluePower."), + Item::GreenPowerI => format!("Increases CONSTRUCT GreenPower."), + Item::GRDI => format!("Increases CONSTRUCT GreenPower + RedPower."), + Item::GBDI => format!("Increases CONSTRUCT GreenPower + BluePower."), + Item::RBDI => format!("Increases CONSTRUCT RedPower + BluePower."), // 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::AmplifyI | @@ -432,12 +432,12 @@ impl Item { Item::BanishI | Item::BanishII | Item::BanishIII => 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::BlastI | Item::BlastII | - Item::BlastIII => format!("Deals blue damage {:?}% blue power.", self.into_skill().unwrap().multiplier()), + Item::BlastIII => format!("Deals Blue Damage {:?}% Blue Power.", self.into_skill().unwrap().multiplier()), Item::ChaosI | Item::ChaosII | @@ -447,19 +447,18 @@ impl Item { Item::ClutchI | Item::ClutchII | - Item::ClutchIII => format!("Cryp cannot be KO'd while active. - Additionally provides immunity to disables."), + Item::ClutchIII => format!("Construct cannot be KO'd while active. Additionally provides immunity to disables."), Item::Corrupt => format!( - "Self targetting defensive for {:?}T. Applies corrupt to attackers dealing blue damage {:?}% blue power per turn for {:?}T.", + "Self targetting defensive for {:?}T. Applies corrupt to attackers dealing BlueDamage {:?}% \ + BluePower per turn for {:?}T.", self.into_skill().unwrap().effect().first().unwrap().get_duration(), Skill::Corrupt.multiplier(), self.into_skill().unwrap().effect().last().unwrap().get_duration()), - Item::CurseI | - Item::CurseII | - Item::CurseIII => format!( + Item::CurseII | + Item::CurseIII => format!( "Increases red and blue damage taken by {:?}%. Lasts {:?}T", self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100, self.into_skill().unwrap().effect().first().unwrap().get_duration()), @@ -475,14 +474,14 @@ impl Item { Item::Hostility => format!( "Gain Hostility for {:?}T. {} Hatred lasts {:?}T", self.into_skill().unwrap().effect().first().unwrap().get_duration(), - "When attacked by Hostility you gain Hatred which increased red and blue power based on damage taken.", + "When attacked by Hostility you gain Hatred which increased red and blue power based on Damage taken.", self.into_skill().unwrap().effect().last().unwrap().get_duration()), Item::Haste => format!( "Haste increases Speed by {:?}%, Red based Attack skills will strike again dealing {:?}{}. Lasts {:?}T", self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100, Skill::HasteStrike.multiplier(), - "% Speed as Red Damage", + "% Speed as RedDamage", self.into_skill().unwrap().effect().first().unwrap().get_duration()), Item::HealI | @@ -495,12 +494,11 @@ impl Item { Hexed targets cannot cast any skills.", self.into_skill().unwrap().effect().first().unwrap().get_duration()), - Item::Impurity => format!( "Impurity increases Green Power by {:?}%, Blue based Attack skills will blast again dealing {:?}{}. Lasts {:?}T", self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100, Skill::ImpureBlast.multiplier(), - "% Green Power as Blue Damage", + "% GreenPower as BluePower", self.into_skill().unwrap().effect().first().unwrap().get_duration()), Item::InvertI | @@ -515,12 +513,12 @@ 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::RiposteI.multiplier()), Item::PurgeI | Item::PurgeII | - Item::PurgeIII => format!("Remove buffs from target cryp"), + Item::PurgeIII => format!("Remove buffs from target construct"), Item::PurifyI | Item::PurifyII | @@ -533,6 +531,7 @@ impl Item { Item::ReflectIII => format!( "Reflect incoming skills to source. Lasts {:?}T", self.into_skill().unwrap().effect().first().unwrap().get_duration()), + Item::RechargeI | Item::RechargeII | Item::RechargeIII => format!( @@ -542,13 +541,13 @@ impl Item { Item::RuinI | Item::RuinII | Item::RuinIII => 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::ScatterI | Item::ScatterII | Item::ScatterIII => 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 Life {:?}% of BluePower", self.into_skill().unwrap().multiplier()), Item::SilenceI | @@ -557,61 +556,68 @@ impl Item { "Block the target from using blue skills for {:?}T and deals blue damage {:?}% blue power. {}", self.into_skill().unwrap().effect().first().unwrap().get_duration(), self.into_skill().unwrap().multiplier(), - "Deals 45% more damage per blue skill on target"), + "Deals 45% more Damage per blue skill on target"), + + Item::RechargeI | + Item::RechargeII | + Item::RechargeIII => format!( + "Recharge Red and Blue Life based on {:?} RedPower and BluePower", + self.into_skill().unwrap().multiplier()), Item::SlayI | Item::SlayII | Item::SlayIII => format!( - "Deals red damage {:?}% red power and provides self healing based on damage dealt.", + "Deals RedDamage {:?}% RedPower and provides self healing based on damage dealt.", self.into_skill().unwrap().multiplier()), Item::SleepI | Item::SleepII | Item::SleepIII => format!( - "Stun for {:?}T and heal for {:?}% green power.", + "Stun for {:?}T and heal for {:?}% GreenPower.", self.into_skill().unwrap().effect().first().unwrap().get_duration(), self.into_skill().unwrap().multiplier()), Item::SnareI | Item::SnareII | Item::SnareIII => format!( - "Block the target from using red skills for {:?}T and deals red damage {:?}% red power. {}", + "Block the target from using red skills for {:?}T and deals RedDamage {:?}% RedPower. {}", self.into_skill().unwrap().effect().first().unwrap().get_duration(), self.into_skill().unwrap().multiplier(), - "Deals 35% more damage per red skill on target"), + "Deals 35% more Damage per red skill on target"), Item::StrangleI | Item::StrangleII | Item::StrangleIII => format!( "Strangle the target disabling skills from both the caster and the target. - While strangling deal red damage each turn {:?}% red power. Lasts {:?}T.", + While strangling deal RedDamage each turn {:?}% RedPower. Lasts {:?}T.", self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().effect().first().unwrap().get_duration()), Item::StrikeI | Item::StrikeII | Item::StrikeIII => format!( - "Hits at maximum speed dealing red damage {:?}% red power", + "Hits at maximum speed dealing RedDamage {:?}% RedPower", self.into_skill().unwrap().multiplier()), Item::SiphonI | Item::SiphonII | Item::SiphonIII => format!( - "Deals blue damage {:?}% blue power each turn and heals caster based on damage dealt. Lasts {:?}T", + "Deals BlueDamage {:?}% BluePower each turn and heals caster based on Damage dealt. Lasts {:?}T", self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().effect().first().unwrap().get_duration()), Item::TauntI | Item::TauntII | - Item::TauntIII => format!("{} {:?}T. Recharges RedLife for {:?} red power.", - "Taunt redirects skills against the team to target, lasts", + Item::TauntIII => format!("Taunt redirects skills against the team to target, lasts {:?}T.\ + Recharges RedLife for {:?} RedPower.", self.into_skill().unwrap().effect().first().unwrap().get_duration(), self.into_skill().unwrap().multiplier()), Item::ThrowI | Item::ThrowII | Item::ThrowIII => format!( - "Stun the target for {:?}T and applies Vulnerable increasing red damage taken by {:?}% for {:?}T", + "Stun the target for {:?}T and applies Vulnerable increasing RedDamage taken by {:?}% for {:?}T", + self.into_skill().unwrap().effect().first().unwrap().get_duration(), self.into_skill().unwrap().effect().first().unwrap().get_multiplier() - 100, self.into_skill().unwrap().effect().last().unwrap().get_duration()), @@ -619,12 +625,10 @@ impl Item { Item::TriageI | Item::TriageII | Item::TriageIII => format!( - "Heals target for {:?}% green power each turn. Lasts {:?}T", + "Heals target for {:?}% GreenPower each turn. Lasts {:?}T", self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().effect().first().unwrap().get_duration()), - - _ => format!("..."), } } @@ -721,12 +725,12 @@ impl Item { Item::ChaosII => vec![Item::ChaosI, Item::ChaosI, Item::ChaosI], Item::ChaosIII => vec![Item::ChaosII, Item::ChaosII, Item::ChaosII], - Item::RedDamageI => vec![Item::Damage, Item::Red, Item::Red], - Item::GreenDamageI => vec![Item::Damage, Item::Green, Item::Green], - Item::BlueDamageI => vec![Item::Damage, Item::Blue, Item::Blue], - Item::GRDI => vec![Item::Damage, Item::Red, Item::Green], - Item::GBDI => vec![Item::Damage, Item::Green, Item::Blue], - Item::RBDI => vec![Item::Damage, Item::Red, Item::Blue], + Item::RedPowerI => vec![Item::Power, Item::Red, Item::Red], + Item::GreenPowerI => vec![Item::Power, Item::Green, Item::Green], + Item::BluePowerI => vec![Item::Power, Item::Blue, Item::Blue], + Item::GRDI => vec![Item::Power, Item::Red, Item::Green], + Item::GBDI => vec![Item::Power, Item::Green, Item::Blue], + Item::RBDI => vec![Item::Power, Item::Red, Item::Blue], Item::RedLifeI => vec![Item::Life, Item::Red, Item::Red], Item::GreenLifeI => vec![Item::Life, Item::Green, Item::Green], @@ -864,10 +868,10 @@ impl From for Item { Spec::GBSpeedI => Item::GBSpeedI, Spec::RBSpeedI => Item::RBSpeedI, - Spec::Damage => Item::Damage, - Spec::RedDamageI => Item::RedDamageI, - Spec::BlueDamageI => Item::BlueDamageI, - Spec::GreenDamageI => Item::GreenDamageI, + Spec::Power => Item::Power, + Spec::RedPowerI => Item::RedPowerI, + Spec::BluePowerI => Item::BluePowerI, + Spec::GreenPowerI => Item::GreenPowerI, Spec::GRDI => Item::GRDI, Spec::GBDI => Item::GBDI, Spec::RBDI => Item::RBDI, @@ -904,8 +908,10 @@ pub fn get_combos() -> Vec { Combo { components: Item::ScatterI.combo(), item: Item::ScatterI }, Combo { components: Item::ScatterII.combo(), item: Item::ScatterII }, Combo { components: Item::ScatterIII.combo(), item: Item::ScatterIII }, + Combo { components: Item::Haste.combo(), item: Item::Haste }, Combo { components: Item::Impurity.combo(), item: Item::Impurity }, + Combo { components: Item::AmplifyI.combo(), item: Item::AmplifyI }, Combo { components: Item::AmplifyII.combo(), item: Item::AmplifyII }, Combo { components: Item::AmplifyIII.combo(), item: Item::AmplifyIII }, @@ -938,7 +944,9 @@ pub fn get_combos() -> Vec { Combo { components: Item::PurifyI.combo(), item: Item::PurifyI }, Combo { components: Item::PurifyII.combo(), item: Item::PurifyII }, Combo { components: Item::PurifyIII.combo(), item: Item::PurifyIII }, + Combo { components: Item::Corrupt.combo(), item: Item::Corrupt }, + Combo { components: Item::ClutchI.combo(), item: Item::ClutchI }, Combo { components: Item::ClutchII.combo(), item: Item::ClutchII }, Combo { components: Item::ClutchIII.combo(), item: Item::ClutchIII }, @@ -961,7 +969,6 @@ pub fn get_combos() -> Vec { Combo { components: Item::RuinII.combo(), item: Item::RuinII }, Combo { components: Item::RuinIII.combo(), item: Item::RuinIII }, - Combo { components: Item::ThrowI.combo(), item: Item::ThrowI }, Combo { components: Item::ThrowII.combo(), item: Item::ThrowII }, Combo { components: Item::ThrowIII.combo(), item: Item::ThrowIII }, @@ -992,21 +999,21 @@ pub fn get_combos() -> Vec { Combo { components: Item::ChaosII.combo(), item: Item::ChaosII }, Combo { components: Item::ChaosIII.combo(), item: Item::ChaosIII }, - Combo { components: Item::RedDamageI.combo(), item: Item::RedDamageI }, - Combo { components: Item::GreenDamageI.combo(), item: Item::GreenDamageI }, - Combo { components: Item::BlueDamageI.combo(), item: Item::BlueDamageI }, - Combo { components: Item::GRDI.combo(), item: Item::GRDI }, - Combo { components: Item::GBDI.combo(), item: Item::GBDI }, - Combo { components: Item::RBDI.combo(), item: Item::RBDI }, + Combo { components: Item::RedPowerI.combo(), item: Item::RedPowerI }, + Combo { components: Item::GreenPowerI.combo(), item: Item::GreenPowerI }, + Combo { components: Item::BluePowerI.combo(), item: Item::BluePowerI }, + Combo { components: Item::GRDI.combo(), item: Item::GRDI }, + Combo { components: Item::GBDI.combo(), item: Item::GBDI }, + Combo { components: Item::RBDI.combo(), item: Item::RBDI }, - Combo { components: Item::RedLifeI.combo(), item: Item::RedLifeI }, - Combo { components: Item::GreenLifeI.combo(), item: Item::GreenLifeI }, - Combo { components: Item::BlueLifeI.combo(), item: Item::BlueLifeI }, - Combo { components: Item::GRLI.combo(), item: Item::GRLI }, - Combo { components: Item::GBLI.combo(), item: Item::GBLI }, - Combo { components: Item::RBLI.combo(), item: Item::RBLI }, + Combo { components: Item::RedLifeI.combo(), item: Item::RedLifeI }, + Combo { components: Item::GreenLifeI.combo(), item: Item::GreenLifeI }, + Combo { components: Item::BlueLifeI.combo(), item: Item::BlueLifeI }, + Combo { components: Item::GRLI.combo(), item: Item::GRLI }, + Combo { components: Item::GBLI.combo(), item: Item::GBLI }, + Combo { components: Item::RBLI.combo(), item: Item::RBLI }, - Combo { components: Item::RedSpeedI.combo(), item: Item::RedSpeedI }, + Combo { components: Item::RedSpeedI.combo(), item: Item::RedSpeedI }, Combo { components: Item::GreenSpeedI.combo(), item: Item::GreenSpeedI }, Combo { components: Item::BlueSpeedI.combo(), item: Item::BlueSpeedI }, Combo { components: Item::GRSpeedI.combo(), item: Item::GRSpeedI }, diff --git a/server/src/main.rs b/server/src/main.rs index 39e51e00..7fcc6b52 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -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/mnml.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 0d7f0ad1..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}; @@ -57,7 +57,6 @@ impl Rpc { match v.method.as_ref() { "account_create" => (), "account_login" => (), - "account_demo" => (), _ => match account { Some(_) => (), None => return Err(err_msg("auth required")), @@ -70,14 +69,13 @@ impl Rpc { // no auth methods "account_create" => Rpc::account_create(data, &mut tx, client), "account_login" => Rpc::account_login(data, &mut tx, client), - "account_demo" => Rpc::account_demo(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), @@ -88,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), @@ -167,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 { @@ -204,35 +202,35 @@ impl Rpc { } } - fn account_demo(_data: Vec, tx: &mut Transaction, _client: &mut WebSocket) -> Result { - let mut rng = thread_rng(); + // fn account_demo(_data: Vec, tx: &mut Transaction, _client: &mut WebSocket) -> Result { + // let mut rng = thread_rng(); - let acc_name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); + // let acc_name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); - let account = account_create(AccountCreateParams { name: acc_name, password: "grepgrepgrep".to_string() }, tx)?; + // 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)?; + // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); + // construct_spawn(ConstructSpawnParams { name }, tx, &account)?; - let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); - cryp_spawn(CrypSpawnParams { name }, tx, &account)?; + // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); + // construct_spawn(ConstructSpawnParams { name }, tx, &account)?; - let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); - cryp_spawn(CrypSpawnParams { name }, tx, &account)?; + // let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); + // construct_spawn(ConstructSpawnParams { name }, tx, &account)?; - let res = RpcResponse { - method: "account_create".to_string(), - params: RpcResult::Account(account), - }; + // let res = RpcResponse { + // method: "account_create".to_string(), + // params: RpcResult::Account(account), + // }; - return Ok(res); - } + // return Ok(res); + // } - 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)?) }) } @@ -302,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); @@ -356,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); @@ -383,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); @@ -399,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)>), @@ -424,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)] @@ -489,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)] @@ -501,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, } @@ -531,7 +529,7 @@ pub struct AccountLoginParams { } #[derive(Debug,Clone,Serialize,Deserialize)] -struct AccountCrypsMsg { +struct AccountConstructsMsg { method: String, params: (), } @@ -544,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, @@ -559,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)] @@ -585,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)] @@ -640,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, } @@ -653,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, } @@ -676,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 5f7246db..8eab9791 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; @@ -92,7 +92,7 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio Skill::BlastI | Skill::ChaosI | Skill::SiphonI => { - let amount = source.green_damage().pct(Skill::ImpureBlast.multiplier()); + let amount = source.green_power().pct(Skill::ImpureBlast.multiplier()); target.deal_blue_damage(Skill::ImpureBlast, amount) .into_iter() .for_each(|e| resolutions.push(Resolution::new(source, target).event(e))); @@ -275,8 +275,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: _ } => { @@ -298,7 +298,7 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> Event::Immunity { skill: _, immunity } => match immunity.contains(&Effect::Parry) { true => { let im_targ = target.clone(); - let CrypEffect { effect: _, duration: _, meta, tick: _ } = im_targ.effects.iter() + let ConstructEffect { effect: _, duration: _, meta, tick: _ } = im_targ.effects.iter() .find(|e| e.effect == Effect::Parry).unwrap(); let &riposte_skill = match meta { Some(EffectMeta::Skill(s)) => s, @@ -311,8 +311,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; @@ -324,30 +324,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, } @@ -362,23 +362,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, } } @@ -540,14 +540,14 @@ impl Effect { match self { Effect::Vulnerable => vec![Stat::RedDamageTaken], Effect::Block => vec![Stat::RedDamageTaken], - Effect::Buff => vec![Stat::RedDamage, Stat::Speed], + Effect::Buff => vec![Stat::RedPower, Stat::Speed], - Effect::Hatred => vec![Stat::RedDamage, Stat::BlueDamage], + Effect::Hatred => vec![Stat::RedPower, Stat::BluePower], - Effect::Amplify => vec![Stat::RedDamage, Stat::BlueDamage], + Effect::Amplify => vec![Stat::RedPower, Stat::BluePower], Effect::Curse => vec![Stat::BlueDamageTaken], - Effect::Impurity => vec![Stat::GreenDamage], + Effect::Impurity => vec![Stat::GreenPower], Effect::Wither => vec![Stat::GreenDamageTaken], Effect::Haste => vec![Stat::Speed], @@ -890,133 +890,132 @@ impl Skill { } } - pub fn effect(&self) -> Vec { + pub fn effect(&self) -> Vec { match self { // Modifiers - Skill::AmplifyI => vec![CrypEffect {effect: Effect::Amplify, duration: 2, + Skill::AmplifyI => vec![ConstructEffect {effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], - Skill::AmplifyII => vec![CrypEffect {effect: Effect::Amplify, duration: 3, + Skill::AmplifyII => vec![ConstructEffect {effect: Effect::Amplify, duration: 3, meta: Some(EffectMeta::Multiplier(175)), tick: None}], - Skill::AmplifyIII => vec![CrypEffect {effect: Effect::Amplify, duration: 4, + Skill::AmplifyIII => vec![ConstructEffect {effect: Effect::Amplify, duration: 4, meta: Some(EffectMeta::Multiplier(200)), tick: None}], - Skill::BanishI => vec![CrypEffect {effect: Effect::Banish, duration: 1,meta: None, tick: None}], - Skill::BanishII => vec![CrypEffect {effect: Effect::Banish, duration: 2,meta: None, tick: None}], - Skill::BanishIII => vec![CrypEffect {effect: Effect::Banish, duration: 3,meta: None, tick: None}], - Skill::Block => vec![CrypEffect {effect: Effect::Block, duration: 1, + Skill::BanishI => vec![ConstructEffect {effect: Effect::Banish, duration: 1,meta: None, tick: None}], + Skill::BanishII => vec![ConstructEffect {effect: Effect::Banish, duration: 2,meta: None, tick: None}], + Skill::BanishIII => vec![ConstructEffect {effect: Effect::Banish, duration: 3,meta: None, tick: None}], + Skill::Block => vec![ConstructEffect {effect: Effect::Block, duration: 1, meta: Some(EffectMeta::Multiplier(50)), tick: None}], - Skill::Buff => vec![CrypEffect {effect: Effect::Buff, duration: 2, + Skill::Buff => vec![ConstructEffect {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::Corrupt => vec![ConstructEffect {effect: Effect::Corrupt, duration: 2, meta: None, tick: None}, + ConstructEffect {effect: Effect::Corruption, duration: 3, meta: None, tick: None}], - Skill::ClutchI => vec![CrypEffect {effect: Effect::Clutch, duration: 1, meta: None, tick: None }], - Skill::ClutchII => vec![CrypEffect {effect: Effect::Clutch, duration: 2, meta: None, tick: None }], - Skill::ClutchIII => vec![CrypEffect {effect: Effect::Clutch, duration: 3, meta: None, tick: None }], + Skill::ClutchI => vec![ConstructEffect {effect: Effect::Clutch, duration: 1, meta: None, tick: None }], + Skill::ClutchII => vec![ConstructEffect {effect: Effect::Clutch, duration: 2, meta: None, tick: None }], + Skill::ClutchIII => vec![ConstructEffect {effect: Effect::Clutch, duration: 3, meta: None, tick: None }], - Skill::CurseI => vec![CrypEffect {effect: Effect::Curse, duration: 2, + Skill::CurseI => vec![ConstructEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], - Skill::CurseII => vec![CrypEffect {effect: Effect::Curse, duration: 2, + Skill::CurseII => vec![ConstructEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(200)), tick: None}], - Skill::CurseIII => vec![CrypEffect {effect: Effect::Curse, duration: 3, + Skill::CurseIII => vec![ConstructEffect {effect: Effect::Curse, duration: 3, meta: Some(EffectMeta::Multiplier(250)), tick: None}], - Skill::Debuff => vec![CrypEffect {effect: Effect::Slow, duration: 3, + Skill::Debuff => vec![ConstructEffect {effect: Effect::Slow, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }], - Skill::DecayI => vec![CrypEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }, - CrypEffect {effect: Effect::Decay, duration: 3, + Skill::DecayI => vec![ConstructEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }, + ConstructEffect {effect: Effect::Decay, duration: 3, meta: Some(EffectMeta::Skill(Skill::DecayTickI)), tick: None}], - Skill::DecayII => vec![CrypEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(35)), tick: None }, - CrypEffect {effect: Effect::Decay, duration: 3, + Skill::DecayII => vec![ConstructEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(35)), tick: None }, + ConstructEffect {effect: Effect::Decay, duration: 3, meta: Some(EffectMeta::Skill(Skill::DecayTickII)), tick: None}], - Skill::DecayIII => vec![CrypEffect {effect: Effect::Wither, duration: 4, meta: Some(EffectMeta::Multiplier(20)), tick: None }, - CrypEffect {effect: Effect::Decay, duration: 4, + Skill::DecayIII => vec![ConstructEffect {effect: Effect::Wither, duration: 4, meta: Some(EffectMeta::Multiplier(20)), tick: None }, + ConstructEffect {effect: Effect::Decay, duration: 4, meta: Some(EffectMeta::Skill(Skill::DecayTickIII)), tick: None}], - Skill::Haste => vec![CrypEffect {effect: Effect::Haste, duration: 2, + Skill::Haste => vec![ConstructEffect {effect: Effect::Haste, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None }], - Skill::HexI => vec![CrypEffect {effect: Effect::Hex, duration: 2, meta: None, tick: None}], - Skill::HexII => vec![CrypEffect {effect: Effect::Hex, duration: 3, meta: None, tick: None}], - Skill::HexIII => vec![CrypEffect {effect: Effect::Hex, duration: 4, meta: None, tick: None}], + Skill::HexI => vec![ConstructEffect {effect: Effect::Hex, duration: 2, meta: None, tick: None}], + Skill::HexII => vec![ConstructEffect {effect: Effect::Hex, duration: 3, meta: None, tick: None}], + Skill::HexIII => vec![ConstructEffect {effect: Effect::Hex, duration: 4, 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::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![CrypEffect {effect: Effect::Impurity, duration: 3, + Skill::Impurity => vec![ConstructEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }], - Skill::InvertI => vec![CrypEffect {effect: Effect::Invert, duration: 2, meta: None, tick: None}], - Skill::InvertII => vec![CrypEffect {effect: Effect::Invert, duration: 3, meta: None, tick: None}], - Skill::InvertIII => vec![CrypEffect {effect: Effect::Invert, duration: 4, meta: None, tick: None}], + Skill::InvertI => vec![ConstructEffect {effect: Effect::Invert, duration: 2, meta: None, tick: None}], + Skill::InvertII => vec![ConstructEffect {effect: Effect::Invert, duration: 3, meta: None, tick: None}], + Skill::InvertIII => vec![ConstructEffect {effect: Effect::Invert, duration: 4, meta: None, tick: None}], - Skill::ParryI => vec![CrypEffect {effect: Effect::Parry, duration: 2, + Skill::ParryI => vec![ConstructEffect {effect: Effect::Parry, duration: 2, meta: Some(EffectMeta::Skill(Skill::RiposteI)), tick: None}], - Skill::ParryII => vec![CrypEffect {effect: Effect::Parry, duration: 2, + Skill::ParryII => vec![ConstructEffect {effect: Effect::Parry, duration: 2, meta: Some(EffectMeta::Skill(Skill::RiposteII)), tick: None}], - Skill::ParryIII => vec![CrypEffect {effect: Effect::Parry, duration: 2, + Skill::ParryIII => vec![ConstructEffect {effect: Effect::Parry, duration: 2, meta: Some(EffectMeta::Skill(Skill::RiposteIII)), tick: None}], - Skill::ReflectI => vec![CrypEffect {effect: Effect::Reflect, duration: 1, meta: None, tick: None }], - Skill::ReflectII => vec![CrypEffect {effect: Effect::Reflect, duration: 2, meta: None, tick: None }], - Skill::ReflectIII => vec![CrypEffect {effect: Effect::Reflect, duration: 3, meta: None, tick: None }], + Skill::ReflectI => vec![ConstructEffect {effect: Effect::Reflect, duration: 1, meta: None, tick: None }], + Skill::ReflectII => vec![ConstructEffect {effect: Effect::Reflect, duration: 2, meta: None, tick: None }], + Skill::ReflectIII => vec![ConstructEffect {effect: Effect::Reflect, duration: 3, meta: None, tick: None }], - Skill::ThrowI => 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::ThrowII => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}, - CrypEffect {effect: Effect::Vulnerable, duration: 4, meta: Some(EffectMeta::Multiplier(200)), tick: None}], - Skill::ThrowIII => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}, - CrypEffect {effect: Effect::Vulnerable, duration: 4, meta: Some(EffectMeta::Multiplier(250)), tick: None}], + Skill::ThrowI => 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::ThrowII => vec![ConstructEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}, + ConstructEffect {effect: Effect::Vulnerable, duration: 4, meta: Some(EffectMeta::Multiplier(200)), tick: None}], + Skill::ThrowIII => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}, + ConstructEffect {effect: Effect::Vulnerable, duration: 4, meta: Some(EffectMeta::Multiplier(250)), tick: None}], - Skill::RuinI => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}], - Skill::RuinII => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}], - Skill::RuinIII => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], + Skill::RuinI => vec![ConstructEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}], + Skill::RuinII => vec![ConstructEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}], + Skill::RuinIII => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], - Skill::ScatterI => vec![CrypEffect {effect: Effect::Scatter, duration: 2, meta: None, tick: None}], - Skill::ScatterII => vec![CrypEffect {effect: Effect::Scatter, duration: 3, meta: None, tick: None}], - Skill::ScatterIII => vec![CrypEffect {effect: Effect::Scatter, duration: 4, meta: None, tick: None}], + Skill::ScatterI => vec![ConstructEffect {effect: Effect::Scatter, duration: 2, meta: None, tick: None}], + Skill::ScatterII => vec![ConstructEffect {effect: Effect::Scatter, duration: 3, meta: None, tick: None}], + Skill::ScatterIII => vec![ConstructEffect {effect: Effect::Scatter, duration: 4, meta: None, tick: None}], - Skill::SilenceI => vec![CrypEffect {effect: Effect::Silence, duration: 2, meta: None, tick: None}], - Skill::SilenceII => vec![CrypEffect {effect: Effect::Silence, duration: 3, meta: None, tick: None}], - Skill::SilenceIII => vec![CrypEffect {effect: Effect::Silence, duration: 4, meta: None, tick: None}], + Skill::SilenceI => vec![ConstructEffect {effect: Effect::Silence, duration: 2, meta: None, tick: None}], + Skill::SilenceII => vec![ConstructEffect {effect: Effect::Silence, duration: 3, meta: None, tick: None}], + Skill::SilenceIII => vec![ConstructEffect {effect: Effect::Silence, duration: 4, meta: None, tick: None}], - Skill::SiphonI => vec![CrypEffect {effect: Effect::Siphon, duration: 2, + Skill::SiphonI => vec![ConstructEffect {effect: Effect::Siphon, duration: 2, meta: Some(EffectMeta::Skill(Skill::SiphonTickI)), tick: None}], - Skill::SiphonII => vec![CrypEffect {effect: Effect::Siphon, duration: 3, + Skill::SiphonII => vec![ConstructEffect {effect: Effect::Siphon, duration: 3, meta: Some(EffectMeta::Skill(Skill::SiphonTickII)), tick: None}], - Skill::SiphonIII => vec![CrypEffect {effect: Effect::Siphon, duration: 4, + Skill::SiphonIII => vec![ConstructEffect {effect: Effect::Siphon, duration: 4, meta: Some(EffectMeta::Skill(Skill::SiphonTickIII)), tick: None}], - Skill::SleepI => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], - Skill::SleepII => vec![CrypEffect {effect: Effect::Stun, duration: 3, meta: None, tick: None}], - Skill::SleepIII => vec![CrypEffect {effect: Effect::Stun, duration: 4, meta: None, tick: None}], + Skill::SleepI => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], + Skill::SleepII => vec![ConstructEffect {effect: Effect::Stun, duration: 3, meta: None, tick: None}], + Skill::SleepIII => vec![ConstructEffect {effect: Effect::Stun, duration: 4, meta: None, tick: None}], - Skill::SnareI => vec![CrypEffect {effect: Effect::Snare, duration: 2, meta: None, tick: None}], - Skill::SnareII => vec![CrypEffect {effect: Effect::Snare, duration: 3, meta: None, tick: None}], - Skill::SnareIII => vec![CrypEffect {effect: Effect::Snare, duration: 4, meta: None, tick: None}], + Skill::SnareI => vec![ConstructEffect {effect: Effect::Snare, duration: 2, meta: None, tick: None}], + Skill::SnareII => vec![ConstructEffect {effect: Effect::Snare, duration: 3, meta: None, tick: None}], + Skill::SnareIII => vec![ConstructEffect {effect: Effect::Snare, duration: 4, meta: None, tick: None}], - Skill::StrangleI => vec![CrypEffect {effect: Effect::Strangle, duration: 2, + Skill::StrangleI => vec![ConstructEffect {effect: Effect::Strangle, duration: 2, meta: Some(EffectMeta::Skill(Skill::StrangleTickI)), tick: None}], - Skill::StrangleII => vec![CrypEffect {effect: Effect::Strangle, duration: 2, + Skill::StrangleII => vec![ConstructEffect {effect: Effect::Strangle, duration: 2, meta: Some(EffectMeta::Skill(Skill::StrangleTickII)), tick: None}], - Skill::StrangleIII => vec![CrypEffect {effect: Effect::Strangle, duration: 2, + Skill::StrangleIII => vec![ConstructEffect {effect: Effect::Strangle, duration: 2, meta: Some(EffectMeta::Skill(Skill::StrangleTickIII)), tick: None}], - Skill::Stun => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], + Skill::Stun => vec![ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], - Skill::TauntI => vec![CrypEffect {effect: Effect::Taunt, duration: 2, meta: None, tick: None}], - Skill::TauntII => vec![CrypEffect {effect: Effect::Taunt, duration: 3, meta: None, tick: None}], - Skill::TauntIII => vec![CrypEffect {effect: Effect::Taunt, duration: 4, meta: None, tick: None}], + Skill::TauntI => vec![ConstructEffect {effect: Effect::Taunt, duration: 2, meta: None, tick: None}], + Skill::TauntII => vec![ConstructEffect {effect: Effect::Taunt, duration: 3, meta: None, tick: None}], + Skill::TauntIII => vec![ConstructEffect {effect: Effect::Taunt, duration: 4, meta: None, tick: None}], - Skill::TriageI => vec![CrypEffect {effect: Effect::Triage, duration: 2, + Skill::TriageI => vec![ConstructEffect {effect: Effect::Triage, duration: 2, meta: Some(EffectMeta::Skill(Skill::TriageTickI)), tick: None}], - Skill::TriageII => vec![CrypEffect {effect: Effect::Triage, duration: 3, + Skill::TriageII => vec![ConstructEffect {effect: Effect::Triage, duration: 3, meta: Some(EffectMeta::Skill(Skill::TriageTickII)), tick: None}], - Skill::TriageIII => vec![CrypEffect {effect: Effect::Triage, duration: 4, + Skill::TriageIII => vec![ConstructEffect {effect: Effect::Triage, duration: 4, meta: Some(EffectMeta::Skill(Skill::TriageTickIII)), 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); @@ -1354,7 +1353,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))); @@ -1362,8 +1361,8 @@ 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 { - let amount = source.red_damage().pct(skill.multiplier()); +fn attack(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.red_power().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1371,8 +1370,8 @@ 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 { - let amount = source.red_damage().pct(skill.multiplier()); +fn strike(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.red_power().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1380,30 +1379,30 @@ 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 { - let amount = source.red_damage().pct(skill.multiplier()); +fn injure(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.red_power().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); 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()); + + let amount = source.green_power().pct(skill.multiplier()); target.deal_green_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1411,14 +1410,14 @@ 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 { - let red_amount = source.red_damage().pct(skill.multiplier()); +fn taunt(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let red_amount = source.red_power().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); skill.effect().into_iter() @@ -1426,30 +1425,28 @@ 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 { - let CrypEffect { effect, duration, meta, tick: _ } = skill.effect().first().unwrap().clone(); +fn strangle(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let ConstructEffect { effect, duration, meta, tick: _ } = skill.effect().first().unwrap().clone(); let tick_skill = match meta { Some(EffectMeta::Skill(s)) => s, _ => panic!("no strangle tick skill"), }; - let strangle = CrypEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); + let strangle = ConstructEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); 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, tick_skill); } -fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = source.red_damage().pct(skill.multiplier()); +fn strangle_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.red_power().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1459,7 +1456,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 })); } @@ -1467,20 +1464,20 @@ 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 { - let red_amount = source.red_damage().pct(skill.multiplier()); +fn parry(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let red_amount = source.red_power().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); skill.effect().into_iter() @@ -1488,8 +1485,8 @@ 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 { - let amount = source.red_damage().pct(skill.multiplier()); +fn riposte(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.red_power().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1497,7 +1494,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))))); @@ -1508,7 +1505,7 @@ fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: false => acc, }); - let amount = source.red_damage().pct(skill.multiplier()).pct(s_multi); + let amount = source.red_power().pct(skill.multiplier()).pct(s_multi); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1517,8 +1514,8 @@ 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 { - let amount = source.red_damage().pct(skill.multiplier()); +fn slay(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.red_power().pct(skill.multiplier()); let slay_events = target.deal_red_damage(skill, amount); for e in slay_events { @@ -1537,93 +1534,92 @@ 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 { - let amount = source.green_damage().pct(skill.multiplier()); +fn heal(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.green_power().pct(skill.multiplier()); target.deal_green_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } -fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let CrypEffect { effect, duration, meta, tick: _ } = skill.effect().first().unwrap().clone(); +fn triage(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let ConstructEffect { effect, duration, meta, tick: _ } = skill.effect().first().unwrap().clone(); let tick_skill = match meta { Some(EffectMeta::Skill(s)) => s, _ => panic!("no triage tick skill"), }; - let triage = CrypEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); + let triage = ConstructEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); results.push(Resolution::new(source, target).event(target.add_effect(skill, triage))); - return triage_tick(source, target, results, tick_skill); } -fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = source.green_damage().pct(skill.multiplier()); +fn triage_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.green_power().pct(skill.multiplier()); target.deal_green_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); 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); + let amount = source.blue_power().pct(skill.multiplier() + b_rng); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); let r_rng: u64 = rng.gen_range(0, 30); - let amount = source.red_damage().pct(skill.multiplier() + r_rng); + let amount = source.red_power().pct(skill.multiplier() + r_rng); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } -fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = source.blue_damage().pct(skill.multiplier()); +fn blast(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.blue_power().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); 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 { let wither = skill.effect().first().unwrap().clone(); results.push(Resolution::new(source, target).event(target.add_effect(skill, wither))); - let CrypEffect { effect, duration, meta, tick: _ } = skill.effect().last().unwrap().clone(); + let ConstructEffect { effect, duration, meta, tick: _ } = skill.effect().last().unwrap().clone(); let tick_skill = match meta { Some(EffectMeta::Skill(s)) => s, _ => panic!("no decay tick skill"), }; - let decay = CrypEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); + let decay = ConstructEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); results.push(Resolution::new(source, target).event(target.add_effect(skill, decay))); return decay_tick(source, target, results, tick_skill); } -fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = source.blue_damage().pct(skill.multiplier()); +fn decay_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.blue_power().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1632,13 +1628,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)); @@ -1646,34 +1642,34 @@ 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 { - let amount = source.blue_damage().pct(skill.multiplier()); +fn corruption_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.blue_power().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); 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)); @@ -1681,56 +1677,56 @@ 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))))); - let blue_amount = source.blue_damage().pct(skill.multiplier()); + let blue_amount = source.blue_power().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount))); return results;; } -fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let red_amount = source.red_damage().pct(skill.multiplier()); - let blue_amount = source.blue_damage().pct(skill.multiplier()); +fn recharge(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let red_amount = source.red_power().pct(skill.multiplier()); + let blue_amount = source.blue_power().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, blue_amount))); return results; } -fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let CrypEffect { effect, duration, meta, tick: _ } = skill.effect().first().unwrap().clone(); +fn siphon(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let ConstructEffect { effect, duration, meta, tick: _ } = skill.effect().first().unwrap().clone(); let tick_skill = match meta { Some(EffectMeta::Skill(s)) => s, _ => panic!("no siphon tick skill"), }; - let siphon = CrypEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); + let siphon = ConstructEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill)); results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon))); return siphon_tick(source, target, results, tick_skill); } -fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = source.blue_damage().pct(skill.multiplier()); +fn siphon_tick(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = source.blue_power().pct(skill.multiplier()); let siphon_events = target.deal_blue_damage(skill, amount); for e in siphon_events { @@ -1749,8 +1745,8 @@ 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 { - let blue_amount = source.blue_damage().pct(skill.multiplier()); +fn scatter(source: &mut Construct, target: &mut Construct, mut results: Resolutions, skill: Skill) -> Resolutions { + let blue_amount = source.blue_power().pct(skill.multiplier()); results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount))); skill.effect().into_iter().for_each(|e| { @@ -1761,13 +1757,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), @@ -1787,7 +1783,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))))); @@ -1798,7 +1794,7 @@ fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill false => acc, }); - let amount = source.blue_damage().pct(skill.multiplier()).pct(s_multi); + let amount = source.blue_power().pct(skill.multiplier()).pct(s_multi); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1806,7 +1802,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) { @@ -1817,9 +1813,9 @@ 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()); + let amount = source.green_power().pct(skill.multiplier()); while let Some(i) = target.effects .iter() .position(|ce| ce.effect.category() == EffectCategory::Debuff) { @@ -1833,7 +1829,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; @@ -1845,11 +1841,11 @@ mod tests { #[test] fn heal_test() { - let mut x = Cryp::new() + let mut x = Construct::new() .named(&"muji".to_string()) .learn(Skill::HealI); - let mut y = Cryp::new() + let mut y = Construct::new() .named(&"camel".to_string()) .learn(Skill::HealI); @@ -1860,10 +1856,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::DecayI); @@ -1877,14 +1873,14 @@ 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 - x.red_damage.force(100); + x.red_power.force(100); y.green_life.force(500); block(&mut y.clone(), &mut y, vec![], Skill::Block); @@ -1901,13 +1897,13 @@ 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 + x.red_power.force(10000000000000); // multiplication of int max will cause overflow clutch(&mut y.clone(), &mut y, vec![], Skill::ClutchI); assert!(y.affected(Effect::Clutch)); @@ -1931,10 +1927,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![]); @@ -1944,16 +1940,16 @@ 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 y.red_life.force(64); y.red_life.reduce(64); - x.red_damage.force(256 + 64); + x.red_power.force(256 + 64); invert(&mut y.clone(), &mut y, vec![], Skill::InvertI); assert!(y.affected(Effect::Invert)); @@ -1983,10 +1979,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::ReflectI); @@ -2012,10 +2008,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); @@ -2049,14 +2045,14 @@ 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 - x.blue_damage.force(50); + x.blue_power.force(50); // remove all mitigation y.red_life.force(0); @@ -2073,10 +2069,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); @@ -2100,7 +2096,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::SilenceI); @@ -2110,19 +2106,19 @@ 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); + x.blue_power.force(50); amplify(&mut x.clone(), &mut x, vec![], Skill::AmplifyI); assert!(x.effects.iter().any(|e| e.effect == Effect::Amplify)); - assert_eq!(x.blue_damage(), 75); + assert_eq!(x.blue_power(), 75); } #[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::DecayI); diff --git a/server/src/spec.rs b/server/src/spec.rs index d1406908..014c3d18 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)] @@ -20,10 +20,10 @@ pub enum Spec { GBLI, RBLI, - Damage, - RedDamageI, - GreenDamageI, - BlueDamageI, + Power, + RedPowerI, + GreenPowerI, + BluePowerI, GRDI, GBDI, RBDI, @@ -32,13 +32,13 @@ pub enum Spec { impl Spec { pub fn affects(&self) -> Vec { match *self { - Spec::Damage => vec![Stat::BlueDamage, Stat::RedDamage, Stat::GreenDamage], - Spec::RedDamageI => vec![Stat::RedDamage], - Spec::GreenDamageI => vec![Stat::GreenDamage], - Spec::BlueDamageI => vec![Stat::BlueDamage], - Spec::GRDI => vec![Stat::GreenDamage, Stat::RedDamage], - Spec::GBDI => vec![Stat::GreenDamage, Stat::BlueDamage], - Spec::RBDI => vec![Stat::RedDamage, Stat::BlueDamage], + Spec::Power => vec![Stat::BluePower, Stat::RedPower, Stat::GreenPower], + Spec::RedPowerI => vec![Stat::RedPower], + Spec::GreenPowerI => vec![Stat::GreenPower], + Spec::BluePowerI => vec![Stat::BluePower], + Spec::GRDI => vec![Stat::GreenPower, Stat::RedPower], + Spec::GBDI => vec![Stat::GreenPower, Stat::BluePower], + Spec::RBDI => vec![Stat::RedPower, Stat::BluePower], Spec::Speed => vec![Stat::Speed], Spec::RedSpeedI => vec![Stat::Speed], @@ -59,26 +59,26 @@ 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), - Spec::RedDamageI => modified + { + // Upgrades to Power Spec + Spec::Power => modified + base.pct(5), + Spec::RedPowerI => modified + { let mut pct = 10; if player_colours.red >= 5 { pct += 10 }; if player_colours.red >= 10 { pct += 20 }; if player_colours.red >= 20 { pct += 40 }; base.pct(pct) }, - Spec::GreenDamageI => modified + { + Spec::GreenPowerI => modified + { let mut pct = 10; if player_colours.green >= 5 { pct += 10 }; if player_colours.green >= 10 { pct += 20 }; if player_colours.green >= 20 { pct += 40 }; base.pct(pct) }, - Spec::BlueDamageI => modified + { + Spec::BluePowerI => modified + { let mut pct = 10; if player_colours.blue >= 5 { pct += 10 }; if player_colours.blue >= 10 { pct += 20 }; @@ -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 3446ef9b..91161137 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::*; @@ -70,7 +70,7 @@ impl Vbox { ]; let specs = vec![ - (Item::Damage, 1), + (Item::Power, 1), (Item::Life, 1), (Item::Speed, 1), ]; @@ -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);