Skip to content

Commit

Permalink
Реворк gamekit (#13798)
Browse files Browse the repository at this point in the history
* rework_chess

* fix

* fixsprite

* fix

* Update game_kit.dm

* Update game_kit.dm

* fix

* fix_sprite
  • Loading branch information
Riverz1 authored Mar 1, 2025
1 parent ddde69b commit d35620d
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 16 deletions.
32 changes: 17 additions & 15 deletions code/game/objects/game_kit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,41 @@
. = ..()
//Parts of this terrible string is being changed into codename of pieces, and then - transformed into pictures
board_stat = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
selected = "CR"
selected = "CW"

/obj/item/weapon/game_kit/MouseDrop(mob/user)
. = ..()
if (user == usr && !usr.restrained() && usr.stat == CONSCIOUS && (usr.contents.Find(src) || Adjacent(usr)))
interact(user)

/obj/item/weapon/game_kit/proc/update()
var/dat = text("<a href='byond://?src=\ref[];mode=hia'>[]</a> <a href='byond://?src=\ref[];mode=remove'>remove</a> <a href='byond://?src=\ref[];reverse=\ref[src]'>invert board</a> <HR><table width= 256 border= 0 height= 256 cellspacing= 0 cellpadding= 0 >", src, (selected ? text("Selected: []", selected) : "Nothing Selected"), src, src)
var/dat = text("<a href='byond://?src=\ref[];mode=hia'>[]</a> <a href='byond://?src=\ref[];mode=remove'>remove</a> <a href='byond://?src=\ref[];reverse=\ref[src]'>invert board</a> <HR><table style='width: 100%; max-width: 512px; border-collapse: collapse;'>", src, (selected ? text("Selected: []", selected) : "Nothing Selected"), src, src)
//board interface update
for (var/y = 1 to 8)
dat += "<tr>"
dat += "<tr style='aspect-ratio: 1 / 1;'>"

for (var/x = 1 to 8)
var/color = (y + x) % 2 ? "#999999" : istype(src, /obj/item/weapon/game_kit/chaplain) ? "#a2fad1" : "#ffffff" //Color the squares in black and white or black and green in case of the chaplain kit.
var/piece = copytext(board_stat, ((y - 1) * 8 + x) * 2 - 1, ((y - 1) * 8 + x) * 2 + 1) //Copy the part of the board_stat string.
dat += "<td style='background-color:[color]' width=32 height=32>"
if (piece != "BB") //If it is not "BB", but codename of the piece, then place picture of this piece onto the board
dat += "<a class='nobg' href='byond://?src=\ref[src];s_board=[x] [y]'><img src=[piece].png width=32 height=32 border=0>"
else //If it is "BB" - place empty square
dat += "<a class='nobg' href='byond://?src=\ref[src];s_board=[x] [y]'><img src=none.png width=32 height=32 border=0>"
var/color = (y + x) % 2 ? "#999999" : istype(src, /obj/item/weapon/game_kit/chaplain) ? "#a2fad1" : "#ffffff"
var/piece = copytext(board_stat, ((y - 1) * 8 + x) * 2 - 1, ((y - 1) * 8 + x) * 2 + 1)
dat += "<td style='background-color:[color]; padding: 0; text-align: center; aspect-ratio: 1 / 1; width: 12.5%;'>"
if (piece != "BB")
dat += "<a class='nobg' href='byond://?src=\ref[src];s_board=[x] [y]'><img src=[piece].png style='width: 100%; height: 100%; object-fit: contain;'></a>" // Сохраняем пропорции изображения
else
dat += "<a class='nobg' href='byond://?src=\ref[src];s_board=[x] [y]'><img src=none.png style='width: 100%; height: 100%; object-fit: contain;'></a>" // Сохраняем пропорции изображения
dat += "</td>"
dat += "</tr>"

//Pieces for people to click and place on the board
dat += "</table><HR><B>Chips:</B><BR>"
for (var/piece in list("CB", "CR"))
dat += "<a class='nobg' href='byond://?src=\ref[src];s_piece=[piece]'><img src=[piece].png width=32 height=32 border=0></a>"
for (var/piece in list("CB", "CW", "KB", "KW"))
dat += "<a class='nobg' href='byond://?src=\ref[src];s_piece=[piece]'><img src=[piece].png style='width: 32px; height: 32px; object-fit: contain;'></a>"

dat += "<HR><B>Chess pieces:</B><BR>"
for (var/piece in list("WP", "WK", "WQ", "WI", "WN", "WR"))
dat += "<a class='nobg' href='byond://?src=\ref[src];s_piece=[piece]'><img src=[piece].png width=32 height=32 border=0></a>"
dat += "<a class='nobg' href='byond://?src=\ref[src];s_piece=[piece]'><img src=[piece].png style='width: 32px; height: 32px; object-fit: contain;'></a>"
dat += "<br>"
for (var/piece in list("BP", "BK", "BQ", "BI", "BN", "BR"))
dat += "<a class='nobg' href='byond://?src=\ref[src];s_piece=[piece]'><img src=[piece].png width=32 height=32 border=0></a>"
dat += "<a class='nobg' href='byond://?src=\ref[src];s_piece=[piece]'><img src=[piece].png style='width: 32px; height: 32px; object-fit: contain;'></a>"
data = dat

/obj/item/weapon/game_kit/attack_ai(mob/user)
Expand Down Expand Up @@ -107,7 +107,7 @@
if (!( data ))
update()

var/datum/browser/popup = new(user, "game_kit", "Game Board", 400, 515, ntheme = CSS_THEME_LIGHT)
var/datum/browser/popup = new(user, "game_kit", "Game Board", 320, 390, ntheme = CSS_THEME_LIGHT)
popup.set_content(data)
popup.open()

Expand Down Expand Up @@ -166,6 +166,7 @@
if (place)
board_stat = text("[][][]", copytext(board_stat, 1, place), selected, copytext(board_stat, place + 2, 129))
selected = null
playsound(src, 'sound/misc/chess_move.ogg', VOL_EFFECTS_MASTER)
else
if (selected == "remove")
var/place = ((ty - 1) * 8 + tx) * 2 - 1
Expand All @@ -188,6 +189,7 @@
else
if (place)
board_stat = text("[][][]", copytext(board_stat, 1, place), selected, copytext(board_stat, place + 2, 129))
playsound(src, 'sound/misc/chess_move.ogg', VOL_EFFECTS_MASTER)
add_fingerprint(usr)
update()
for(var/mob/M in viewers(1, src.loc)) //If someone is playing with us - they would see that we made a move.
Expand Down
4 changes: 3 additions & 1 deletion code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
"WK.png" = 'icons/obj/chess/board_WK.png',
"WP.png" = 'icons/obj/chess/board_WP.png',
"CB.png" = 'icons/obj/chess/board_CB.png',
"CR.png" = 'icons/obj/chess/board_CR.png',
"CW.png" = 'icons/obj/chess/board_CW.png',
"KB.png" = 'icons/obj/chess/board_CB_king.png',
"KW.png" = 'icons/obj/chess/board_CW_king.png',
"none.png" = 'icons/obj/chess/board_none.png'
)

Expand Down
Binary file modified icons/obj/chess/board_BI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_BK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_BN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_BP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_BQ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_BR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_CB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/obj/chess/board_CB_king.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/obj/chess/board_CR.png
Binary file not shown.
Binary file added icons/obj/chess/board_CW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/obj/chess/board_CW_king.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_WI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_WK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_WN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_WP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_WQ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obj/chess/board_WR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sound/misc/chess_move.ogg
Binary file not shown.

0 comments on commit d35620d

Please sign in to comment.