Oh, the fun we shall have, the games we shall play!
-
@xaade said in Oh, the fun we shall have, the games we shall play!:
Ok.
Let's look at the equivalent.
I have too many variables to send to this method, so I wrote this god-class to store them all.
It also says that you aren't treating your controller methods as atomic, so you're probably submitting the entire application state to one method to write all the updates, or something like that. Just speculating on why you'd need to send that much data.
I didn't write this thing. I am just stuck maintaining it. And I have been forbidden from fixing it. Yes, they abused the tenets of MVC, and class responsibilities, and data integrity. I am pretty sure they molested a squirrel while they were at it as well. nothing I can do about it but soldier on and fix what I am allowed to fix. I save my fighting for the battles I am willing to die for :P
[ninja edits!]
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
I am pretty sure EVERYONE uses MVC wrong
-
@Yamikuronue said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
I am pretty sure EVERYONE uses MVC wrong
That seems ... suspiciously like work ...
I'll look at it, just not today, okay? I tieeerd :/
-
@Vaire No rush! It's mafiabot, most of it's a hot mess anyway :D
-
@Yamikuronue said in Oh, the fun we shall have, the games we shall play!:
@Vaire No rush! It's mafiabot, most of it's a hot mess anyway :D
@Yamikuronue ... Yami ... Yami ... Yami ... if I didn't already like you, I would have bailed out immediately on this. UML PLUS Github? You are getting Hipster all over me with the Github, and yucky marketing/Enterprise-PM with the UML. It's just ... eww ;_;
Anyway, as for the critique you wanted, here you go:
The class design looks fine, although I question the main view containing the ReportError aspect. I would have isolated that, myself. Maybe a partial view or something? I tend to like errors having their own paths and channels in stuff. Paths and channels that cannot be blocked or otherwise interfered with.
As for the MVC aspects of it, I would say that is a good, clean implementation of the design pattern. You have one data access layer/object, a couple of controllers, a view to display it in (:waves:, hiiii SPA) and your modeling wraps it all together.
You may want to split your player controller into several controllers (or just sub classes in the controller) that handle actions, reactions, bookkeeping, and game-tracking, as things grow. But single responsibilities aren't really needed for a smaller project like this looks like.
Since I don't play the game (or know what it is), I am not sure what responsibilities the Mod controller has, but they seem small enough in scope to keep in that one controller.
Your DAO seems a little brief, though. I see lots of gets, but no sets. Just not showing that because it isn't public?
But yeah, looks clean enough to me. Most of what I could say about it if I went into depth, would be nitpicky stuff and style stuff. And it is just the UML so hard for me to do a deep dive ;)
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Your DAO seems a little brief, though. I see lots of gets, but no sets. Just not showing that because it isn't public?
Honestly i ran out of energy to catalogue the monster DAO. We need to revamp it Glad you like!
The code's also on github if you want it, but trust me, you don't want it until after I finish some planned overhauls
-
@Yamikuronue I still don't know what the mafia game IS ... so I can't really want it yet. Maybe I will figure out what it is some day though. If someone explains it to me.
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
I still don't know what the mafia game IS ... so I can't really want it yet. Maybe I will figure out what it is some day though. If someone explains it to me.
If we're talking about the one we play here on the forums, the basic concept is:
- A group of people are locked in a room
- Said people can be a member of zero or more factions (such as Mafia), each intending on some kind of win condition (i.e. everyone against you must die)
- At the start, most nobody knows what faction anyone else belongs to, with exception to factions that can communicate with other faction members
- Each "day" cycle, players are given the chance to "lynch" another player by majority vote. Most commonly, as soon as a majority vote is achieved, the "day" cycle ends and begins "night"
- Each "night" cycle gives the opportunity for enabled players to take a particular action, such as a given faction targeting another player to kill. These actions have their own rules and balances.
- The day/night cycle continues until a win condition is met.
- Town (aka unaffiliated) almost always loses.
I'm sure there's a wiki link someone will provide with more fun to be had elsewhere.
-
@Vaire Basic concept: you have a number of players. They are all secretly assigned factions, typically Town and Mafia. The game has two alternating phases: Day and Night. During the Day, all players may vote to lynch one player (Day ends when the time expires or one player has been lynched). During the Night phase, any player with a night action may act (typically, Mafia get a night action "kill one person", also known as a "faction kill"). Typically, Mafia know who they all are, but Town do not know who the Mafia is. Town wins when all Mafia are dead. Mafia wins when they control the lynch (> 50% of living players are Mafia). Upon death, typically, a player's faction and special abilities are revealed.
It gets more complicated as you add special abilities, but that's the basic game. Accalia's about to run one with no special abilities if you want to learn.
-
@Tsaukpaetra So, similar to Legend of Green Dragon, then, but all in text form as free-form RPG? Why does it need code to control it then?
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
I still don't know what the mafia game IS ...
i invited you to club Ded so you cqan watch the game that starts on the 7th unfold.
bring the popcorn because this one's gonna be a hell of a ride!
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Why does it need code to control it then?
It doesn't. The bot is a DM helper, meant to calculate votes and announce when someone has been lynched, so the players can keep up to date on vote totals when the DM is offline. Games can and have been played with the DM counting votes by hand.
-
@accalia said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
I still don't know what the mafia game IS ...
i invited you to club Ded so you cqan watch the game that starts on the 7th unfold.
bring the popcorn because this one's gonna be a hell of a ride!
All righty
-
@Yamikuronue said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Why does it need code to control it then?
It doesn't. The bot is a DM helper, meant to calculate votes and announce when someone has been lynched, so the players can keep up to date on vote totals when the DM is offline. Games can and have been played with the DM counting votes by hand.
Ah, gotcha, similar to the DM helpers Wizards have released for D&D then. I understand now.
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
All righty
one of us! one of us!
:-D
-
@accalia said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
All righty
one of us! one of us!
:-D
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
@accalia said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
All righty
one of us! one of us!
:-D
once the mafia bug bites you it's very hard to let go.
we'll have you playing the game proper any time now!
-
@accalia said in Oh, the fun we shall have, the games we shall play!:
once the mafia bug bites you it's very hard to let go.
we'll have you playing the game proper any time now!
-
@Vaire yes, yes we will.....
oh we will....
Heh...
HA!
HA!
MWA HA HA HA HA HA HA HA HA HA HA!
-ahem-
it'll be fun.
-
@accalia said in Oh, the fun we shall have, the games we shall play!:
@Vaire yes, yes we will.....
oh we will....
Heh...
HA!
HA!
MWA HA HA HA HA HA HA HA HA HA HA!
-ahem-
it'll be fun.
-
-
@blakeyrat said in Oh, the fun we shall have, the games we shall play!:
You can easily submit a form without loading a page. There's about 36 different ways of accomplishing that.
How you do that without JavaScript?
-
By setting the form's target to an iframe or
_blank
.You still have to tell the user somehow that the form was submitted successfully, though. So when the iframe or the new window loads, it should probably provide the user that feedback. Still, that requires no Javascript at all.
-
@Vaire Are all AHAX infested forms ones that require that the user be able to submit without refreshing the page (e.g. for some kind of validation voodoo)? Hell, does even one of those pages require that? If not, then yeah, that's pretty fucked up.
-
@sloosecannon Accept headers would be more appropriate (, hopefully)
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
JSON deserializer they are using (native .NET System.Web.Script.Serialization.JavaScriptSerializer) is choking on the amount of data the JSON object contains.
You know what WOULDN'T have choked? (sing along, kids, if you know the words)
A basic HTTP Post of the FORM ITSELF to the controller. The form even HAS a submit button (it calls the JS functions that wrap everything up in JSON, then submits via jQuery, because JS!)!And MVC.NET has LONG had the FormCollection to EASILY catch the contents of a submitted form and do stuff with it.
It sounds like the AJAX request has been structured poorly. In my opinion, you shouldn't need to submit a JSON request from AJAX unless the object is complicated.
fucking hipsters
Italians are encouraging me to wear skinny jeans and lumberjack shirts. I refuse to grow a beard again though.
-
@ScholRLEA said in Oh, the fun we shall have, the games we shall play!:
@Vaire Are all AHAX infested forms ones that require that the user be able to submit without refreshing the page (e.g. for some kind of validation voodoo)? Hell, does even one of those pages require that? If not, then yeah, that's pretty fucked up.
No, literally none of the forms require that the user be able to submit without refreshing. As a matter of fact, once the page is done submitting via AJAX with a JSON object, once it gets the response back, it calls out again with AJAX to refresh the page manually to pull the new data from the database. Why? Because frontend!!11!!oneoneoneone!!! I guess? I don't know. The person I inherited this from didn't SEEM like a raging hipster when I met them on their way out. But they were CLEARLY practicing to be a "frontend dev" by the looks of the codebase [sigh]
-
@Shoreline said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
JSON deserializer they are using (native .NET System.Web.Script.Serialization.JavaScriptSerializer) is choking on the amount of data the JSON object contains.
You know what WOULDN'T have choked? (sing along, kids, if you know the words)
A basic HTTP Post of the FORM ITSELF to the controller. The form even HAS a submit button (it calls the JS functions that wrap everything up in JSON, then submits via jQuery, because JS!)!And MVC.NET has LONG had the FormCollection to EASILY catch the contents of a submitted form and do stuff with it.
It sounds like the AJAX request has been structured poorly. In my opinion, you shouldn't need to submit a JSON request from AJAX unless the object is complicated.
fucking hipsters
Italians are encouraging me to wear skinny jeans and lumberjack shirts. I refuse to grow a beard again though.
To be fair, the object is VERY complicated. But, all of the data is ALREADY IN THE FORM ANYWAY, and could have been scooped out of the FormCollection object built into MVC.NET [sigh]
Don't do it, don't bow to hipster peer pressure! Skinny jeans are a work of the devil =_=
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
As a matter of fact, once the page is done submitting via AJAX with a JSON object, once it gets the response back, it calls out again with AJAX to refresh the page manually to pull the new data from the database.
Does it examine the returned object to determine whether to refresh the page? If not, doing it all via a conventional page load would be good enough. I suspect we're not talking hipsters, we're talking cargo-culting from hipsters…
-
@dkf said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
As a matter of fact, once the page is done submitting via AJAX with a JSON object, once it gets the response back, it calls out again with AJAX to refresh the page manually to pull the new data from the database.
Does it examine the returned object to determine whether to refresh the page? If not, doing it all via a conventional page load would be good enough. I suspect we're not talking hipsters, we're talking cargo-culting from hipsters…
Nope, the page refresh via AJAX will happen regardless of the response, and no, it doesn't look at the response anyway. [sigh] FML. :(
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Yes, they abused the tenants of MVC, and class responsibilities
Wait! MVC is a landlord now? Or did you mean tenets? :D 8)
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Why? Because frontend!!11!!oneoneoneone!!! I guess? I don't know.
Because on a slow connection, for a brief moment between refreshes, the screen goes white. Clearly that's not our branding! It has to go solid #bgcolor instead, or the user will confuse our brand.
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
@Shoreline said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
JSON deserializer they are using (native .NET System.Web.Script.Serialization.JavaScriptSerializer) is choking on the amount of data the JSON object contains.
You know what WOULDN'T have choked? (sing along, kids, if you know the words)
A basic HTTP Post of the FORM ITSELF to the controller. The form even HAS a submit button (it calls the JS functions that wrap everything up in JSON, then submits via jQuery, because JS!)!And MVC.NET has LONG had the FormCollection to EASILY catch the contents of a submitted form and do stuff with it.
It sounds like the AJAX request has been structured poorly. In my opinion, you shouldn't need to submit a JSON request from AJAX unless the object is complicated.
fucking hipsters
Italians are encouraging me to wear skinny jeans and lumberjack shirts. I refuse to grow a beard again though.
To be fair, the object is VERY complicated. But, all of the data is ALREADY IN THE FORM ANYWAY, and could have been scooped out of the FormCollection object built into MVC.NET [sigh]
Don't do it, don't bow to hipster peer pressure! Skinny jeans are a work of the devil =_=
IKR. Where the fuck are the pockets on these things?
At least my legs look good.
-
@Shoreline said in Oh, the fun we shall have, the games we shall play!:
Where the fuck are the pockets on these things?
Welcome to the world of women's garments.
-
@Yamikuronue said in Oh, the fun we shall have, the games we shall play!:
@Shoreline said in Oh, the fun we shall have, the games we shall play!:
Where the fuck are the pockets on these things?
Welcome to the world of women's garments.
This is the bulk of why I don't wear women's garments.
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Yes, they abused the tenants of MVC,
If it isn't a classification or type of software or the only way to write software, it also isn't a place to live.
-
@Steve_The_Cynic said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Yes, they abused the tenants of MVC, and class responsibilities
Wait! MVC is a landlord now? Or did you mean tenets? :D 8)
We are no longer friends :/
-
@Yamikuronue said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Why? Because frontend!!11!!oneoneoneone!!! I guess? I don't know.
Because on a slow connection, for a brief moment between refreshes, the screen goes white. Clearly that's not our branding! It has to go solid #bgcolor instead, or the user will confuse our brand.
I am fairly confident that isn't the reason. The company DOES have marketing drones and PR people and sales people, etc. But I generally only ever hear from the sales people.
-
@Shoreline said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
@Shoreline said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
JSON deserializer they are using (native .NET System.Web.Script.Serialization.JavaScriptSerializer) is choking on the amount of data the JSON object contains.
You know what WOULDN'T have choked? (sing along, kids, if you know the words)
A basic HTTP Post of the FORM ITSELF to the controller. The form even HAS a submit button (it calls the JS functions that wrap everything up in JSON, then submits via jQuery, because JS!)!And MVC.NET has LONG had the FormCollection to EASILY catch the contents of a submitted form and do stuff with it.
It sounds like the AJAX request has been structured poorly. In my opinion, you shouldn't need to submit a JSON request from AJAX unless the object is complicated.
fucking hipsters
Italians are encouraging me to wear skinny jeans and lumberjack shirts. I refuse to grow a beard again though.
To be fair, the object is VERY complicated. But, all of the data is ALREADY IN THE FORM ANYWAY, and could have been scooped out of the FormCollection object built into MVC.NET [sigh]
Don't do it, don't bow to hipster peer pressure! Skinny jeans are a work of the devil =_=
IKR. Where the fuck are the pockets on these things?
At least my legs look good.
Booooooooooooooooooo
-
@Yamikuronue said in Oh, the fun we shall have, the games we shall play!:
@Shoreline said in Oh, the fun we shall have, the games we shall play!:
Where the fuck are the pockets on these things?
Welcome to the world of women's garments.
-
@boomzilla said in Oh, the fun we shall have, the games we shall play!:
@Vaire said in Oh, the fun we shall have, the games we shall play!:
Yes, they abused the tenants of MVC,
If it isn't a classification or type of software or the only way to write software, it also isn't a place to live.
You and steve are walking on wafer-thin ice today
-
@Vaire You fall in love so very easily... I'm flattered, but truly, perhaps you should guard your heart a little more judiciously?
-
@Yamikuronue I never said I was going to STAY in love ;)
-
@Vaire said in Oh, the fun we shall have, the games we shall play!:
@Yamikuronue I never said I was going to STAY in love ;)
Faithless!? Fie, for shame!
-
-
@Yamikuronue no kidding, I was borderline hovering over a downvote just because it seemed so... gratuitous.
TBH I really don't like giant picture replies. Especially cartoony ones. Especially pastel cartoony ones. Especially pastel cartoony pony ones. (Side note, I wish the upvote/downvote class was applied to the entire post's <li> element instead of just the button so that I could apply special css to the post based on that.)
-
@anotherusername said in Oh, the fun we shall have, the games we shall play!:
TBH I really don't like giant picture replies. Especially cartoony ones. Especially pastel cartoony ones. Especially pastel cartoony pony ones. (Side note, I wish the upvote/downvote class was applied to the entire post's <li> element instead of just the button so that I could apply special css to the post based on that.)
-
Here's a Stylish rule to mitigate that:
li[data-uid="140763"] img[src^="/uploads/"] { max-height:100px !important; }
-
This is what I ended up doing:
// apply the "upvoted" or "downvoted" classes to the <li> element of the post, in addition to the <a> itself new MutationObserver(m => { var a = []; m.forEach(e => { if (e.attributeName == "class" && e.target.tagName == "A" && e.target.parentElement.matches(".votes")) { a.push(e.target); } else if (e.addedNodes.length) [].forEach.call(e.addedNodes, n => { if (n.querySelectorAll) a = [].concat.apply(a, n.querySelectorAll( "li:not(.upvoted) .upvoted,li:not(.downvoted) .downvoted")); }); }); a.forEach(e => { var c = e.getAttribute("component").match(/\w*v.*/) + "d"; e.closest('li[component="post"]').classList.toggle(c, e.classList.contains(c)); }); }).observe(document.body, {attributes: true, childList: true, subtree: true}); // trigger the MutationObserver once to inspect descendants of the .posts element var p = document.querySelector(".posts"); if (p) p.parentElement.insertBefore(p, p);
Then I used this css to reduce images in downvoted posts to emoji-size:
.topic .posts li.downvoted .content img { max-height: 20px; max-width: 40px; border: none; padding: 0; }
-
@Vaire I was a little disappointed you didn't use GMan there.