x and y are flipped when drinking mate

This commit is contained in:
hyperbel 2023-07-14 11:44:03 +02:00
parent c14aa08283
commit 547561a3ed
2 changed files with 4 additions and 6 deletions

View File

@ -28,7 +28,7 @@ class MateKiste():
self.FlaschenBreite = flaschenAnzahl[0]
self.FlaschenHoehe = flaschenAnzahl[1]
flaschenAnzahl = self.FlaschenBreite * self.FlaschenHoehe
flaschenAnzahl = (self.FlaschenBreite * self.FlaschenHoehe)
self.collection.insert_one({'mateKiste': True, 'status': generate_kiste(flaschenAnzahl)})
self.initialized = True
@ -39,5 +39,5 @@ class MateKiste():
@classmethod
def removeAt(self, x: int, y: int):
position = y * self.FlaschenBreite + x
self.collection.update_one({'mateKiste': True}, {'$set': {'status.' + str(position): False}})
position = x * self.FlaschenBreite + y # for whatever reason y and x are swapped here lamoooo dont touch this
self.collection.update_one({'mateKiste': True}, {'$set': {f'status.{str(position)}': False}})

View File

@ -29,9 +29,7 @@ function getMateStatus(socket) {
const flascheTrinkenButton = document.createElement('button');
flascheTrinkenButton.classList.add('flasche-trinken-button');
flascheTrinkenButton.disabled = !flascheIstVoll;
if (!flascheIstVoll) flascheTrinkenButton.style.backgroundColor = 'red';
flascheTrinkenButton.style.backgroundColor = flascheIstVoll ? '#c88a35' : '#333';
flascheTrinkenButton.style.backgroundColor = '#c88a35';
flascheTrinkenButton.id = `flasche-trinken-button-${x}-${y}`; //TODO: remove and replace with class
flascheTrinkenButton.onclick = () => { flascheTrinken(x, y) };
cell.appendChild(flascheTrinkenButton);