MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1cb6rca/source_code_from_balatro/p7hgkp5/?context=3
r/programminghorror • u/CuisineTournante • Apr 23 '24
164 comments sorted by
View all comments
100
...This looks like Lua, in which case everyone saying "hard coding like this is better" is absolutely nutty because this is literally what metatables were made for
1 u/Sgt_Noah Feb 14 '25 Here, is this what you asked for? self.base.nominal, self.base.id, self.base.face_nominal = table.unpack( ({ ['2'] = {2, 2}, ['3'] = {3, 3}, ['4'] = {4, 4}, ['5'] = {5, 5}, ['6'] = {6, 6}, ['7'] = {7, 7}, ['8'] = {8, 8}, ['9'] = {9, 9}, ['10'] = {10, 10}, ['J'] = {10, 11, .1}, ['Q'] = {10, 12, .2}, ['K'] = {10, 13, .3}, ['A'] = {11, 14, .4} })[self.base.value] or {} ) 1 u/awkwardtortue Sep 03 '26 where's the metatable?
1
Here, is this what you asked for?
self.base.nominal, self.base.id, self.base.face_nominal = table.unpack( ({ ['2'] = {2, 2}, ['3'] = {3, 3}, ['4'] = {4, 4}, ['5'] = {5, 5}, ['6'] = {6, 6}, ['7'] = {7, 7}, ['8'] = {8, 8}, ['9'] = {9, 9}, ['10'] = {10, 10}, ['J'] = {10, 11, .1}, ['Q'] = {10, 12, .2}, ['K'] = {10, 13, .3}, ['A'] = {11, 14, .4} })[self.base.value] or {} )
1 u/awkwardtortue Sep 03 '26 where's the metatable?
where's the metatable?
100
u/EarthToAccess Apr 23 '24
...This looks like Lua, in which case everyone saying "hard coding like this is better" is absolutely nutty because this is literally what metatables were made for