1212 * Theme-aware: reads the current dark/light mode at startup.
1313 */
1414
15- const DevDuel = ( function ( ) {
15+ const DevDuel = ( ( ) => {
1616 const GAME_ID = "dev-duel" ;
1717
1818 // ─── Public entry-point ──────────────────────────────────────────────────
@@ -22,7 +22,7 @@ const DevDuel = (function () {
2222 * @param {{ name:string, role:string, skills:string[] } } opponent
2323 */
2424 function launch ( challenger , opponent ) {
25- GameManager . loadPhaser ( function ( ) {
25+ GameManager . loadPhaser ( ( ) => {
2626 _init ( challenger , opponent ) ;
2727 } ) ;
2828 }
@@ -106,11 +106,27 @@ const DevDuel = (function () {
106106 . setOrigin ( 0.5 ) ;
107107
108108 // Power bars
109- _drawPowerBar ( scene , challenger . name , cPower , W * 0.02 , H - 90 , W * 0.44 , theme ) ;
110- _drawPowerBar ( scene , opponent . name , oPower , W * 0.54 , H - 90 , W * 0.44 , theme ) ;
109+ _drawPowerBar (
110+ scene ,
111+ challenger . name ,
112+ cPower ,
113+ W * 0.02 ,
114+ H - 90 ,
115+ W * 0.44 ,
116+ theme ,
117+ ) ;
118+ _drawPowerBar (
119+ scene ,
120+ opponent . name ,
121+ oPower ,
122+ W * 0.54 ,
123+ H - 90 ,
124+ W * 0.44 ,
125+ theme ,
126+ ) ;
111127
112128 // Animate the battle after a short delay
113- scene . time . delayedCall ( 800 , function ( ) {
129+ scene . time . delayedCall ( 800 , ( ) => {
114130 _animateBattle ( scene , challenger , opponent , cPower , oPower , W , H , theme ) ;
115131 } ) ;
116132 }
@@ -160,7 +176,7 @@ const DevDuel = (function () {
160176
161177 // Top skills (up to 5)
162178 const skills = ( dev . skills || [ ] ) . slice ( 0 , 5 ) ;
163- skills . forEach ( function ( skill , i ) {
179+ skills . forEach ( ( skill , i ) => {
164180 const rarity = skillRarity ( skill ) ;
165181 const color = RARITY_COLORS [ rarity ] || "#94a3b8" ;
166182 scene . add
@@ -199,7 +215,7 @@ const DevDuel = (function () {
199215 w : barW ,
200216 duration : 800 ,
201217 ease : "Power2" ,
202- onUpdate : function ( tween , target ) {
218+ onUpdate : ( tween , target ) => {
203219 fillGfx . clear ( ) ;
204220 fillGfx . fillStyle ( 0x38bdf8 , 1 ) ;
205221 fillGfx . fillRoundedRect ( x , y + 14 , target . w , 10 , 3 ) ;
@@ -215,14 +231,23 @@ const DevDuel = (function () {
215231
216232 // ─── Battle animation ─────────────────────────────────────────────────────
217233
218- function _animateBattle ( scene , challenger , opponent , cPower , oPower , W , H , theme ) {
234+ function _animateBattle (
235+ scene ,
236+ challenger ,
237+ opponent ,
238+ cPower ,
239+ oPower ,
240+ W ,
241+ H ,
242+ theme ,
243+ ) {
219244 // Flash attacks back and forth
220245 let round = 0 ;
221246 const maxRounds = 5 ;
222247
223- const attackFlash = function ( ) {
248+ const attackFlash = ( ) => {
224249 if ( round >= maxRounds ) {
225- scene . time . delayedCall ( 400 , function ( ) {
250+ scene . time . delayedCall ( 400 , ( ) => {
226251 _showResult ( scene , challenger , opponent , cPower , oPower , W , H , theme ) ;
227252 } ) ;
228253 return ;
@@ -242,7 +267,7 @@ const DevDuel = (function () {
242267 x : endX ,
243268 duration : 350 ,
244269 ease : "Power2" ,
245- onComplete : function ( ) {
270+ onComplete : ( ) => {
246271 bolt . destroy ( ) ;
247272 scene . cameras . main . shake ( 120 , 0.008 ) ;
248273 scene . time . delayedCall ( 200 , attackFlash ) ;
@@ -255,7 +280,16 @@ const DevDuel = (function () {
255280
256281 // ─── Result screen ────────────────────────────────────────────────────────
257282
258- function _showResult ( scene , challenger , opponent , cPower , oPower , W , H , theme ) {
283+ function _showResult (
284+ scene ,
285+ challenger ,
286+ opponent ,
287+ cPower ,
288+ oPower ,
289+ W ,
290+ H ,
291+ theme ,
292+ ) {
259293 const challengerWins = cPower >= oPower ;
260294 const winner = challengerWins ? challenger : opponent ;
261295
@@ -291,12 +325,10 @@ const DevDuel = (function () {
291325
292326 const powerDiff = Math . abs ( cPower - oPower ) ;
293327 scene . add
294- . text (
295- W / 2 ,
296- H / 2 + 5 ,
297- "Power advantage: +" + powerDiff + " pts" ,
298- { fontSize : "14px" , fill : "#94a3b8" } ,
299- )
328+ . text ( W / 2 , H / 2 + 5 , "Power advantage: +" + powerDiff + " pts" , {
329+ fontSize : "14px" ,
330+ fill : "#94a3b8" ,
331+ } )
300332 . setOrigin ( 0.5 ) ;
301333
302334 scene . add
@@ -326,7 +358,7 @@ const DevDuel = (function () {
326358 */
327359 function _calcPower ( skills ) {
328360 if ( ! skills || skills . length === 0 ) return 1 ;
329- return skills . reduce ( function ( total , skill ) {
361+ return skills . reduce ( ( total , skill ) => {
330362 const rarity = skillRarity ( skill ) ;
331363 return total + ( RARITY_WEIGHTS [ rarity ] || 1 ) ;
332364 } , 0 ) ;
@@ -355,10 +387,7 @@ function getCardData(cardEl) {
355387 return {
356388 name : ( cardEl . dataset . name || "" ) . trim ( ) ,
357389 role : ( cardEl . dataset . role || "" ) . trim ( ) ,
358- skills : ( cardEl . dataset . skills || "" )
359- . trim ( )
360- . split ( / \s + / )
361- . filter ( Boolean ) ,
390+ skills : ( cardEl . dataset . skills || "" ) . trim ( ) . split ( / \s + / ) . filter ( Boolean ) ,
362391 } ;
363392}
364393
@@ -369,10 +398,10 @@ function getCardData(cardEl) {
369398 * @param {HTMLElement } challengerCard The card element that was clicked.
370399 */
371400function startDuelFromCard ( challengerCard ) {
372- const allCards = Array . from ( document . querySelectorAll ( ".user-card[data-name]" ) ) ;
373- const others = allCards . filter ( function ( c ) {
374- return c !== challengerCard ;
375- } ) ;
401+ const allCards = Array . from (
402+ document . querySelectorAll ( ".user-card[data-name]" ) ,
403+ ) ;
404+ const others = allCards . filter ( ( c ) => c !== challengerCard ) ;
376405
377406 if ( others . length === 0 ) return ;
378407
0 commit comments