auxMsg is working

This commit is contained in:
Iris Lightshard 2023-05-12 22:33:14 -06:00
parent 42bb254d84
commit 7ad9d76f78
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
5 changed files with 36 additions and 18 deletions

View file

@ -232,10 +232,10 @@ func (self *GameTableServer) writeToDB(tableMsg models.TableMessage) error {
} }
} }
if tableMsg.AuxMsg != nil { if tableMsg.AuxMsg != nil {
err := self.dbAdapter.SetAuxMessage(key, *tableMsg.AuxMsg) err := self.dbAdapter.SetAuxMessage(key, *tableMsg.AuxMsg)
if err != nil { if err != nil {
return err return err
} }
} }
} }
} }

View file

@ -17,23 +17,22 @@ type DiceRoll struct {
Timestamp time.Time `json:"timestamp"` Timestamp time.Time `json:"timestamp"`
} }
type Token struct { type Token struct {
Id string `json:"id"` Id string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
SpriteUri string `json:"spriteUrl"` SpriteUri string `json:"spriteUrl"`
X *int `json:"x"` X *int `json:"x"`
Y *int `json:"y"` Y *int `json:"y"`
} }
type Table struct { type Table struct {
Name string `json:"name"` Name string `json:"name"`
Passcode string `json:"passcode"` Passcode string `json:"passcode"`
MapImageUrl string `json:"mapImageUrl"` MapImageUrl string `json:"mapImg"`
DiceRolls []DiceRoll `json:"diceRolls"` DiceRolls []DiceRoll `json:"diceRolls"`
Tokens []Token `json:"tokens"` Tokens []Token `json:"tokens"`
AvailableTokens []Token `json:"availableTokens"` AvailableTokens []Token `json:"availableTokens"`
AuxMessage string `json:"auxMessage"` AuxMessage string `json:"auxMsg"`
} }
type TableMessage struct { type TableMessage struct {

View file

@ -57,9 +57,10 @@
</select> </select>
<input id="dice_note"><button id="dice_submit" onclick="rollDice()">Roll</button> <input id="dice_note"><button id="dice_submit" onclick="rollDice()">Roll</button>
<div id="dice_log"></div> <div id="dice_log"></div>
<div id="aux"></div>
<div id="map"></div> <div id="map"></div>
</main> </main>
<div id="adminWrapper" style="display:none;"> <div id="adminWrapper" style="display:none;">
<div id="adminCtrl"> <div id="adminCtrl">
<button onclick="setTableCreateFormVisible(true)">New Table</button> <button onclick="setTableCreateFormVisible(true)">New Table</button>
<form onsubmit="return false" id="createTableForm" style="display:none;"> <form onsubmit="return false" id="createTableForm" style="display:none;">

View file

@ -39,13 +39,26 @@ function logDice(dice, many) {
} }
} }
function setAuxMsg(msg) {
const auxDiv = document.getElementById("aux");
if (auxDiv) {
console.log("eeee");
auxDiv.innerText = msg;
}
}
function makeUpToDate(table) { function makeUpToDate(table) {
if (table) { if (table) {
if (table.diceRolls) { if (table.diceRolls) {
logDice(table.diceRolls, true); logDice(table.diceRolls, true);
} else if (table.diceRoll) {
logDice(table.diceRoll, false);
} }
if (table.mapImageUrl) { if (table.mapImg) {
setMapImg(table.mapImageUrl); setMapImg(table.mapImg);
}
if (table.auxMsg) {
setAuxMsg(table.auxMsg);
} }
} }
} }
@ -101,13 +114,9 @@ function dial() {
table = data; table = data;
makeUpToDate(table); makeUpToDate(table);
} else { } else {
if (data.diceRoll) { makeUpToDate(data);
logDice(data.diceRoll);
}
if (data.mapImageUrl) {
setMapImg(data.mapImageUrl);
}
} }
console.log(data); console.log(data);
}); });
} }

View file

@ -78,3 +78,12 @@ button:hover {
#dice_log p:not(:last-child) { #dice_log p:not(:last-child) {
border-bottom: solid 1px gray; border-bottom: solid 1px gray;
} }
#aux {
display: block;
background: #fff;
color: #000;
height: auto;
width: auto;
border: solid 1px dimgray;
}