Skip to content

Commit

Permalink
Merge pull request #165 from Ldip999/Tetris
Browse files Browse the repository at this point in the history
Tetris extra monies
  • Loading branch information
Tk420634 authored Dec 23, 2024
2 parents b77e938 + 9cdd4c0 commit dd2c6dc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
30 changes: 23 additions & 7 deletions modular_sand/code/game/machinery/computer/arcade/tetris.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#define TETRIS_SCORE_MAX_SCI 10000
#define TETRIS_TIME_COOLDOWN 600
#define TETRIS_NO_SCIENCE TRUE

//Line bonus defines, for when you clear a set amount of rows in a single go. Beat Fenny with a newspaper if these values are unbalanced, it was their numbers
#define L1_bonus 1
#define L2_bonus 3
#define L3_bonus 9
#define L4_bonus 15
// Cooldown defines
#define TETRIS_COOLDOWN_MAIN cooldown_timer

Expand All @@ -26,17 +30,25 @@
// Sanitize score as an integer
// Restricts maximum score to (default) 100,000
var/temp_score = sanitize_num_clamp(text2num(href_list["tetrisScore"]), max=TETRIS_SCORE_MAX)

var/l1 = sanitize_num_clamp(text2num(href_list["Lines1"]),max= 100)
var/l2 = sanitize_num_clamp(text2num(href_list["Lines2"]), max= 100)
var/l3 = sanitize_num_clamp(text2num(href_list["Lines3"]), max= 100)
var/l4 = sanitize_num_clamp(text2num(href_list["Lines4"]), max = 100)
// Check for high score
if(temp_score > TETRIS_SCORE_HIGH)
// Alert admins
message_admins("[ADMIN_LOOKUPFLW(usr)] [ADMIN_KICK(usr)] has achieved a score of [temp_score] on [src] in [get_area(src.loc)]! Score exceeds configured suspicion threshold.")

// Round and clamp prize count from 0 to (default) 5
var/reward_count = clamp(round(temp_score/TETRIS_REWARD_DIVISOR), 0, TETRIS_PRIZES_MAX)

var/linesbonus = ((l1 * L1_bonus) + (l2*L2_bonus) + (l3*L3_bonus) + (l4 * L4_bonus))
if(linesbonus > 0)
var/obj/item/stack/f13Cash/moneytodrop = new /obj/item/stack/f13Cash/caps(get_turf(src))
moneytodrop.amount = linesbonus
visible_message(span_notice("[src] dispenses [moneytodrop]!"), span_notice("I hear a chime and a clunk."))

// Define score text
var/score_text = (reward_count ? temp_score : "PATHETIC! TRY HARDER")
var/score_text = (reward_count ? temp_score : "You can do it! I believe in you!")

// Display normal message
say("YOUR SCORE: [score_text]!")
Expand All @@ -61,7 +73,7 @@
// Vend prizes
for(var/i = 0; i < reward_count; i++)
prizevend(usr)

// Check if science points are possible and allowed
if((!SSresearch.science_tech) || TETRIS_NO_SCIENCE)
return
Expand Down Expand Up @@ -107,8 +119,8 @@
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=iso-8859-1'>
<title>Telemetry Enhanced Testing and Research Informatic Simulator</title>
<script language='JavaScript'>
function submitScore(s){
window.location.href = 'byond://?src=\ref[src];tetrisScore=' + s;
function submitScore(s,l1,l2,l3,l4){
window.location.href = 'byond://?src=\ref[src];tetrisScore=' + s + '&Lines1=' + l1 + '&Lines2=' + l2 +'&Lines3=' + l3 + "&Lines4="+ l4;
}
</script>
<script language='JavaScript1.2'>
Expand Down Expand Up @@ -168,3 +180,7 @@
#undef TETRIS_TIME_COOLDOWN
#undef TETRIS_NO_SCIENCE
#undef TETRIS_COOLDOWN_MAIN
#undef L1_bonus
#undef L2_bonus
#undef L3_bonus
#undef L4_bonus
24 changes: 22 additions & 2 deletions tgui/src/interfaces/tetris/tetris.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var i, j, IsOver, MaxX=10, MaxY=20, NextCol, Col, Score, Lines, IsHideFocus=true;
var i, j, IsOver, MaxX=10, MaxY=20, NextCol, Col, Score, Lines, IsHideFocus=true, Lines1, Lines2, Lines3, Lines4;
PosX=new Array(4);
PosY=new Array(4);
Delay=new Array(828,620,464,348,260,196,148,112,84,64,48,36,27);
Expand Down Expand Up @@ -74,6 +74,10 @@ function Init(nn)
Score=0;
Level=1;
Lines=0;
Lines1=0;
Lines2=0;
Lines3=0;
Lines4=0;
window.document.ScoreForm.Score.value = Score;
window.document.ScoreForm.Level.value = Level;
window.document.ScoreForm.Lines.value = Lines;
Expand Down Expand Up @@ -102,7 +106,7 @@ function Go()
document.images[PosX[nn]+MaxX*(PosY[nn]-1)].src = Pic[Col+1].src;
}
//if (confirm("Super, you got a score of "+Score+" ! Play again ?")) Init(true);
submitScore(Score);
submitScore(Score,Lines1,Lines2,Lines3,Lines4);
return;
}
for (nn=0; nn<4; nn++)
Expand Down Expand Up @@ -296,6 +300,22 @@ function Remove()
}
}
}
switch(nn){
case 0:
break;
case 1:
Lines1++;
break;
case 2:
Lines2++;
break;
case 3:
Lines3++;
break;
case 4:
Lines4++;
break;
}
Score+=100*nn;
Lines+=nn;
if ((Score>=1500*Level)&&(Level<12)) Level++;
Expand Down

0 comments on commit dd2c6dc

Please sign in to comment.