mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 16:47:13 +01:00
Minesweeper rightclicks (#1211)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request Fixes the rightclicking to flag in minesweeper Also puts it in the game category ## Proof Of Testing dude trust me ## Changelog <!-- If your PR modifies aspects of the game that can be concretely observed by players or admins you should add a changelog. If your change does NOT meet this description, remove this section. Be sure to properly mark your PRs to prevent unnecessary GBP loss. You can read up on GBP and it's effects on PRs in the tgstation guides for contributors. Please note that maintainers freely reserve the right to remove and add tags should they deem it appropriate. You can attempt to finagle the system all you want, but it's best to shoot for clear communication right off the bat. --> 🆑 fix: you can now rightclick to flag in minesweeper /🆑 <!-- Both 🆑's are required for the changelog to work! You can put your name to the right of the first 🆑 if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. --> <!-- By opening a pull request. You have read and understood the repository rules located on the main README.md on this project. -->
This commit is contained in:
@@ -1,171 +0,0 @@
|
||||
#define MINESWEEPER_BEGINNER 1
|
||||
#define MINESWEEPER_INTERMEDIATE 2
|
||||
#define MINESWEEPER_EXPERT 3
|
||||
#define MINESWEEPER_CUSTOM 4
|
||||
|
||||
#define MINESWEEPER_CONTINUE 0
|
||||
#define MINESWEEPER_DEAD 1
|
||||
#define MINESWEEPER_VICTORY 2
|
||||
#define MINESWEEPER_IDLE 3
|
||||
/obj/machinery/computer/arcade/minesweeper
|
||||
name = "Minesweeper"
|
||||
desc = "An arcade machine that generates grids. It seems that the machine sparks and screeches when a grid is generated, as if it cannot cope with the intensity of generating the grid."
|
||||
icon_state = "arcade"
|
||||
circuit = /obj/item/circuitboard/computer/arcade/minesweeper
|
||||
|
||||
var/datum/minesweeper/board
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/Initialize()
|
||||
. = ..()
|
||||
board = new /datum/minesweeper()
|
||||
board.emaggable = TRUE
|
||||
board.host = src
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/Destroy(force)
|
||||
board.host = null
|
||||
QDEL_NULL(board)
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/interact(mob/user, special_state)
|
||||
. = ..()
|
||||
if(!is_operational)
|
||||
return
|
||||
if(board.game_status == MINESWEEPER_IDLE || board.game_status == MINESWEEPER_DEAD || board.game_status == MINESWEEPER_VICTORY)
|
||||
if(obj_flags & EMAGGED)
|
||||
playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_emag2.ogg', 50, 0, extrarange = -3, falloff_exponent = 10)
|
||||
else
|
||||
playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_startup.ogg', 50, 0, extrarange = -3, falloff_exponent = 10)
|
||||
|
||||
if(obj_flags & EMAGGED)
|
||||
do_sparks(5, 1, src)
|
||||
|
||||
add_fingerprint(user)
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_interact(mob/user, datum/tgui/ui)
|
||||
. = ..()
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!is_operational)
|
||||
return
|
||||
if(!ui)
|
||||
ui = new(user, src, "Minesweeper", name)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_assets(mob/user)
|
||||
return list(
|
||||
get_asset_datum(/datum/asset/simple/minesweeper),
|
||||
)
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_data(mob/user)
|
||||
var/list/data = ..()
|
||||
|
||||
data["board_data"] = board.board_data
|
||||
data["game_status"] = board.game_status
|
||||
data["difficulty"] = board.diff_text(board.difficulty)
|
||||
data["current_difficulty"] = board.current_difficulty
|
||||
data["emagged"] = obj_flags & EMAGGED
|
||||
data["flag_mode"] = board.flag_mode
|
||||
data["tickets"] = board.ticket_count
|
||||
data["flags"] = board.flags
|
||||
data["current_mines"] = board.current_mines
|
||||
data["custom_height"] = board.custom_height
|
||||
data["custom_width"] = board.custom_width
|
||||
data["custom_mines"] = board.custom_mines
|
||||
var/display_time = (board.time_frozen ? board.time_frozen : REALTIMEOFDAY - board.starting_time) / 10
|
||||
data["time_string"] = board.starting_time ? "[add_leading(num2text(FLOOR(display_time / 60,1)), 2, "0")]:[add_leading(num2text(display_time % 60), 2, "0")]" : "00:00"
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_act(action, list/params, mob/user)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
switch(action)
|
||||
if("PRG_do_tile")
|
||||
var/x = params["x"]
|
||||
var/y = params["y"]
|
||||
var/flagging = params["flag"]
|
||||
if(!x || !y)
|
||||
return
|
||||
|
||||
return board.do_tile(x,y,flagging,user)
|
||||
|
||||
if("PRG_new_game")
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
board.generate_new_board(board.difficulty)
|
||||
board.current_difficulty = board.diff_text(board.difficulty)
|
||||
board.current_mines = board.mines
|
||||
board.flags = 0
|
||||
board.starting_time = 0
|
||||
return TRUE
|
||||
|
||||
if("PRG_difficulty")
|
||||
var/diff = params["difficulty"]
|
||||
if(!diff)
|
||||
return
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
board.difficulty = diff
|
||||
return TRUE
|
||||
|
||||
if("PRG_height")
|
||||
var/cin = params["height"]
|
||||
if(!cin)
|
||||
return
|
||||
cin = text2num(cin)
|
||||
if(cin < 5 || cin > 17)
|
||||
cin = clamp(cin, 5, 17)
|
||||
board.custom_height = cin
|
||||
board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
board.difficulty = MINESWEEPER_CUSTOM
|
||||
return TRUE
|
||||
|
||||
if("PRG_width")
|
||||
var/cin = params["width"]
|
||||
if(!cin)
|
||||
return
|
||||
cin = text2num(cin)
|
||||
if(cin < 5 || cin > 30)
|
||||
cin = clamp(cin, 5, 30)
|
||||
board.custom_width = cin
|
||||
board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
board.difficulty = MINESWEEPER_CUSTOM
|
||||
return TRUE
|
||||
|
||||
if("PRG_mines")
|
||||
var/cin = params["mines"]
|
||||
if(!cin)
|
||||
return
|
||||
cin = text2num(cin)
|
||||
if(cin < 5 || cin > FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
cin = clamp(cin, 5, FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
board.custom_mines = cin
|
||||
board.difficulty = MINESWEEPER_CUSTOM
|
||||
return TRUE
|
||||
|
||||
if("PRG_toggle_flag")
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
board.flag_mode = !board.flag_mode
|
||||
return TRUE
|
||||
|
||||
if("PRG_tickets")
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
if(board.ticket_count >= 1)
|
||||
new /obj/item/stack/arcadeticket(loc, 1)
|
||||
to_chat(user, span_notice("[src] dispenses a ticket!"))
|
||||
board.ticket_count -= 1
|
||||
else
|
||||
to_chat(user, span_notice("You don't have any stored tickets!"))
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/emag_act(mob/user)
|
||||
if(obj_flags & EMAGGED)
|
||||
return
|
||||
desc = "An arcade machine that generates grids. It's clunking and sparking everywhere, almost as if threatening to explode at any moment!"
|
||||
do_sparks(5, 1, src)
|
||||
obj_flags |= EMAGGED
|
||||
if(board.game_status != MINESWEEPER_CONTINUE)
|
||||
to_chat(user, span_warning("An ominous tune plays from the arcade's speakers!"))
|
||||
playsound(user, 'modular_zubbers/sound/arcade/minesweeper_emag1.ogg', 100, 0, extrarange = 3, falloff_exponent = 10)
|
||||
else //Can't let you do that, star fox!
|
||||
to_chat(user, span_warning("The machine buzzes and sparks... the game has been reset!"))
|
||||
playsound(user, 'sound/machines/buzz-sigh.ogg', 100, 0, extrarange = 3, falloff_exponent = 10) //Loud buzz
|
||||
board.game_status = MINESWEEPER_IDLE
|
||||
+188
-7
@@ -1,13 +1,198 @@
|
||||
/obj/item/circuitboard/computer/arcade/minesweeper
|
||||
name = "Minesweeper"
|
||||
greyscale_colors = CIRCUIT_COLOR_GENERIC
|
||||
build_path = /obj/machinery/computer/arcade/minesweeper
|
||||
|
||||
#define MINESWEEPER_BEGINNER 1
|
||||
#define MINESWEEPER_INTERMEDIATE 2
|
||||
#define MINESWEEPER_EXPERT 3
|
||||
#define MINESWEEPER_CUSTOM 4
|
||||
|
||||
#define MINESWEEPER_CONTINUE 0
|
||||
#define MINESWEEPER_DEAD 1
|
||||
#define MINESWEEPER_VICTORY 2
|
||||
#define MINESWEEPER_IDLE 3
|
||||
|
||||
/* MINESWEEPER MACHINE */
|
||||
/// The machine itself.
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper
|
||||
name = "Minesweeper"
|
||||
desc = "An arcade machine that generates grids. It seems that the machine sparks and screeches when a grid is generated, as if it cannot cope with the intensity of generating the grid."
|
||||
icon_state = "arcade"
|
||||
circuit = /obj/item/circuitboard/computer/arcade/minesweeper
|
||||
|
||||
var/datum/minesweeper/board
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/Initialize()
|
||||
. = ..()
|
||||
board = new /datum/minesweeper()
|
||||
board.emaggable = TRUE
|
||||
board.host = src
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/Destroy(force)
|
||||
board.host = null
|
||||
QDEL_NULL(board)
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/interact(mob/user, special_state)
|
||||
. = ..()
|
||||
if(!is_operational)
|
||||
return
|
||||
if(board.game_status == MINESWEEPER_IDLE || board.game_status == MINESWEEPER_DEAD || board.game_status == MINESWEEPER_VICTORY)
|
||||
if(obj_flags & EMAGGED)
|
||||
playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_emag2.ogg', 50, 0, extrarange = -3, falloff_exponent = 10)
|
||||
else
|
||||
playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_startup.ogg', 50, 0, extrarange = -3, falloff_exponent = 10)
|
||||
|
||||
if(obj_flags & EMAGGED)
|
||||
do_sparks(5, 1, src)
|
||||
|
||||
add_fingerprint(user)
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_interact(mob/user, datum/tgui/ui)
|
||||
. = ..()
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!is_operational)
|
||||
return
|
||||
if(!ui)
|
||||
ui = new(user, src, "Minesweeper", name)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_assets(mob/user)
|
||||
return list(
|
||||
get_asset_datum(/datum/asset/simple/minesweeper),
|
||||
)
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_data(mob/user)
|
||||
var/list/data = ..()
|
||||
|
||||
data["board_data"] = board.board_data
|
||||
data["game_status"] = board.game_status
|
||||
data["difficulty"] = board.diff_text(board.difficulty)
|
||||
data["current_difficulty"] = board.current_difficulty
|
||||
data["emagged"] = obj_flags & EMAGGED
|
||||
data["flag_mode"] = board.flag_mode
|
||||
data["tickets"] = board.ticket_count
|
||||
data["flags"] = board.flags
|
||||
data["current_mines"] = board.current_mines
|
||||
data["custom_height"] = board.custom_height
|
||||
data["custom_width"] = board.custom_width
|
||||
data["custom_mines"] = board.custom_mines
|
||||
var/display_time = (board.time_frozen ? board.time_frozen : REALTIMEOFDAY - board.starting_time) / 10
|
||||
data["time_string"] = board.starting_time ? "[add_leading(num2text(FLOOR(display_time / 60,1)), 2, "0")]:[add_leading(num2text(display_time % 60), 2, "0")]" : "00:00"
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/ui_act(action, list/params, mob/user)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
switch(action)
|
||||
if("PRG_do_tile")
|
||||
var/x = params["x"]
|
||||
var/y = params["y"]
|
||||
var/flagging = params["flag"]
|
||||
if(!x || !y)
|
||||
return
|
||||
|
||||
return board.do_tile(x,y,flagging,user)
|
||||
|
||||
if("PRG_new_game")
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
board.generate_new_board(board.difficulty)
|
||||
board.current_difficulty = board.diff_text(board.difficulty)
|
||||
board.current_mines = board.mines
|
||||
board.flags = 0
|
||||
board.starting_time = 0
|
||||
return TRUE
|
||||
|
||||
if("PRG_difficulty")
|
||||
var/diff = params["difficulty"]
|
||||
if(!diff)
|
||||
return
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
board.difficulty = diff
|
||||
return TRUE
|
||||
|
||||
if("PRG_height")
|
||||
var/cin = params["height"]
|
||||
if(!cin)
|
||||
return
|
||||
cin = text2num(cin)
|
||||
if(cin < 5 || cin > 17)
|
||||
cin = clamp(cin, 5, 17)
|
||||
board.custom_height = cin
|
||||
board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
board.difficulty = MINESWEEPER_CUSTOM
|
||||
return TRUE
|
||||
|
||||
if("PRG_width")
|
||||
var/cin = params["width"]
|
||||
if(!cin)
|
||||
return
|
||||
cin = text2num(cin)
|
||||
if(cin < 5 || cin > 30)
|
||||
cin = clamp(cin, 5, 30)
|
||||
board.custom_width = cin
|
||||
board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
board.difficulty = MINESWEEPER_CUSTOM
|
||||
return TRUE
|
||||
|
||||
if("PRG_mines")
|
||||
var/cin = params["mines"]
|
||||
if(!cin)
|
||||
return
|
||||
cin = text2num(cin)
|
||||
if(cin < 5 || cin > FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
cin = clamp(cin, 5, FLOOR(board.custom_width*board.custom_height/2,1))
|
||||
board.custom_mines = cin
|
||||
board.difficulty = MINESWEEPER_CUSTOM
|
||||
return TRUE
|
||||
|
||||
if("PRG_toggle_flag")
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
board.flag_mode = !board.flag_mode
|
||||
return TRUE
|
||||
|
||||
if("PRG_tickets")
|
||||
board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg')
|
||||
if(board.ticket_count >= 1)
|
||||
new /obj/item/stack/arcadeticket(loc, 1)
|
||||
to_chat(user, span_notice("[src] dispenses a ticket!"))
|
||||
board.ticket_count -= 1
|
||||
else
|
||||
to_chat(user, span_notice("You don't have any stored tickets!"))
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/computer/arcade/minesweeper/emag_act(mob/user)
|
||||
if(obj_flags & EMAGGED)
|
||||
return
|
||||
desc = "An arcade machine that generates grids. It's clunking and sparking everywhere, almost as if threatening to explode at any moment!"
|
||||
do_sparks(5, 1, src)
|
||||
obj_flags |= EMAGGED
|
||||
if(board.game_status != MINESWEEPER_CONTINUE)
|
||||
to_chat(user, span_warning("An ominous tune plays from the arcade's speakers!"))
|
||||
playsound(user, 'modular_zubbers/sound/arcade/minesweeper_emag1.ogg', 100, 0, extrarange = 3, falloff_exponent = 10)
|
||||
else //Can't let you do that, star fox!
|
||||
to_chat(user, span_warning("The machine buzzes and sparks... the game has been reset!"))
|
||||
playsound(user, 'sound/machines/buzz-sigh.ogg', 100, 0, extrarange = 3, falloff_exponent = 10) //Loud buzz
|
||||
board.game_status = MINESWEEPER_IDLE
|
||||
|
||||
|
||||
|
||||
|
||||
/// COMPUTER MINESWEEPER PROGRAM
|
||||
/datum/computer_file/program/minesweeper
|
||||
filename = "minesweeper"
|
||||
filedesc = "Nanotrasen Micro Arcade: Minesweeper"
|
||||
// program_icon_state = "arcade"
|
||||
extended_desc = "A port of the classic game 'Minesweeper', redesigned to run on tablets."
|
||||
// requires_ntnet = FALSE
|
||||
size = 6
|
||||
tgui_id = "NtosMinesweeper"
|
||||
program_icon = "gamepad"
|
||||
|
||||
downloader_category = PROGRAM_CATEGORY_GAMES
|
||||
|
||||
var/datum/minesweeper/board
|
||||
|
||||
/datum/computer_file/program/minesweeper/New(obj/item/modular_computer/comp)
|
||||
@@ -144,11 +329,7 @@
|
||||
COOLDOWN_DECLARE(new_game_cd)
|
||||
|
||||
/datum/minesweeper/proc/play_snd(sound)
|
||||
/*if(istype(host, /obj/item/modular_computer))
|
||||
var/obj/item/modular_computer/comp = host
|
||||
playsound(get_turf(), sound, 50, 0)
|
||||
else*/
|
||||
playsound(get_turf(host), sound, 50, 0, extrarange = -3, falloff_exponent = 10)
|
||||
playsound(get_turf(host), sound, 25, 0, extrarange = -6)
|
||||
|
||||
/datum/minesweeper/proc/vis_msg(msg, local_msg)
|
||||
if(istype(host, /obj/item/modular_computer))
|
||||
@@ -1,4 +0,0 @@
|
||||
/obj/item/circuitboard/computer/arcade/minesweeper
|
||||
name = "Minesweeper"
|
||||
greyscale_colors = CIRCUIT_COLOR_GENERIC
|
||||
build_path = /obj/machinery/computer/arcade/minesweeper
|
||||
+1
-3
@@ -8218,7 +8218,6 @@
|
||||
#include "modular_zubbers\code\game\machinery\burger_reactor_sniffer\reactor_sniffer_processing.dm"
|
||||
#include "modular_zubbers\code\game\machinery\burger_reactor_sniffer\reactor_sniffer_wires.dm"
|
||||
#include "modular_zubbers\code\game\machinery\camera\camera.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\crew.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade\arcade.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_classic.dm"
|
||||
@@ -8226,6 +8225,7 @@
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_oh_god.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_special.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_toy.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade\minesweeper.dm"
|
||||
#include "modular_zubbers\code\game\machinery\computer\arcade\~arcade_weights_final.dm"
|
||||
#include "modular_zubbers\code\game\machinery\doors\firedoor.dm"
|
||||
#include "modular_zubbers\code\game\machinery\vending\multisec.dm"
|
||||
@@ -8240,7 +8240,6 @@
|
||||
#include "modular_zubbers\code\game\objects\items\plushes.dm"
|
||||
#include "modular_zubbers\code\game\objects\items\reshirevolver.dm"
|
||||
#include "modular_zubbers\code\game\objects\items\ai_modules\full_lawsets.dm"
|
||||
#include "modular_zubbers\code\game\objects\items\circuitboards\computer_circuitboards.dm"
|
||||
#include "modular_zubbers\code\game\objects\items\circuitboards\machine_circuitboards.dm"
|
||||
#include "modular_zubbers\code\game\objects\items\food\halloween_chocolate.dm"
|
||||
#include "modular_zubbers\code\game\objects\items\food\meatslab.dm"
|
||||
@@ -8447,7 +8446,6 @@
|
||||
#include "modular_zubbers\code\modules\mod\mod_ai.dm"
|
||||
#include "modular_zubbers\code\modules\mod\mod_theme.dm"
|
||||
#include "modular_zubbers\code\modules\mod\mod_types.dm"
|
||||
#include "modular_zubbers\code\modules\modular_computers\file_system\programs\minesweeper.dm"
|
||||
#include "modular_zubbers\code\modules\movespeed\modifiers\status_effects.dm"
|
||||
#include "modular_zubbers\code\modules\opposing_force\code\items.dm"
|
||||
#include "modular_zubbers\code\modules\opposing_force\code\equipment\antagonist_powers.dm"
|
||||
|
||||
@@ -65,7 +65,7 @@ export const MinesweeperContent = (props, context) => {
|
||||
flag: false,
|
||||
})
|
||||
}
|
||||
oncontextmenu={(eve) => {
|
||||
onContextMenu={(eve) => {
|
||||
eve.preventDefault();
|
||||
act('PRG_do_tile', {
|
||||
x: xind + 1,
|
||||
|
||||
Reference in New Issue
Block a user