Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tetris extra monies #165

Merged
merged 8 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 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,15 +30,24 @@
// 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 = 0
linesbonus = (l1 * L1_bonus) + (l2*L2_bonus) + (l3*L3_bonus) + (l4 * L4_bonus)
if(linesbonus > 0)
var/obj/item/stack/f13Cash/caps/linesbonuscash = new /obj/item/stack/f13Cash/caps();
linesbonuscash.amount = linesbonus;
visible_message(span_notice("[src] dispenses [linesbonuscash]!"), span_notice("I hear a chime and a clunk."))
linesbonuscash.forceMove(get_turf(src))
// Define score text
var/score_text = (reward_count ? temp_score : "PATHETIC! TRY HARDER")

Expand All @@ -61,7 +74,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 +120,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 +181,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
Loading