  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs: | reply to yock Re: Which Vote count do you prefer??
Hmmm, I was unaware that there were such concerns. |
|
  yock TFTC Premium join:2000-11-21 Fairfield, OH
| reply to drew Maybe, but we can't host this thing off-site. At one point I had a subdomain here at DSLR, but I suspect it has been removed due to lack of use. Justin had some real concerns about having anything even remotely official-looking being hosted off-site and we all agreed that keeping it in-house was necessary. That's why I'm more hip to the desktop application route. |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs: | reply to yock The one thing is that all of this could be implemented in PHP with a MySQL backing right? You could have a website and use it to hold the persistent data and be available from anywhere. |
|
  yock TFTC Premium join:2000-11-21 Fairfield, OH | reply to drew Yeah, Gomez and I worked on the initial concept of a JSP app to manage all of this. It was just too much. I've been working on implementing what we worked on originally in a small Swing app, but that still takes time. |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs:
·wavebroadband
| reply to yock Mine is Visual Basic .NET, not C++. That, by itself, would make it more difficult to translate to Java.
You know what's interesting? I think our local forum Mod is a Java developer. How about that?  |
|
  Johnny Premium join:2001-06-27 Atlanta, GA
·Comcast
| reply to yock You now have this really killer app, but it's platform-dependent upon OSX. Drew is making progress on his Visual C++ Windows app, but that's another app limited to one OS. How can we take all of these individual contributions and make them into something everyone can use and enjoy?
Well, I was at one point ready to do some Java learning, but decided to stick with Objective-C as there are so many things I still need to learn about the Cocoa API. You can call the Cocoa API from Java or from Python or from Ruby, but that still only runs on a Mac.
So all I can think of is to set the specs down to minimum (i.e., no night action code, no attempt to screen-scrape) and let someone who knows Java look at my code and Drew's code and just transliterate it. For the basic voting/unvoting it should not take long.
A decision will have to be made as to whether we want to support persistent game state (day, night, roles already generated or not, roster complete or not) across re-launch of the app. That is the most tedious part.
I do think the game flavor generation and role generation calls to random.org are simple enough that the Java port should include them. I used Cocoa's built-in NSURLConnection API, but even a shell call to curl would do the same thing. You call once to get the flavor, then again to get the roles, then plug the roles into array templates.
For games other than C9 or F11 or other pre-fixed setups, the role generation could just be set to read off an entered list of role names and randomize the list. I have not coded that but it wouldn't be a lot of work. I'd probably do it with a separate modal sheet that the user filled in with the role names and a button that said Randomize. Then it would add those to the Role field of the players that had already been entered.
The automatic timing countdown could be left out also. Mine isn't fully complete yet, but given an integer it counts down the hours to deadline and it preserves the count across launches. In the complete version it would go to random.org at the end of each Night and get the next day's duration, based on minimum and maximum set by the user on the UI. That's just about 5 lines of code.
Having written this thing twice now, I can help with logic, but I don't know Java and I don't have any interest in Web stuff. |
|
  muzscman Mr. President Premium,VIP join:2002-02-15 Florissant, MO clubs:
·AT&T U-Verse
| reply to yock said by yock :This is the mental process I went through when I wanted to build the web application that handled it all. Gomez put together a data model and some templates for code generation but I just didn't have the time or the knowledge to contribute interface code. You now have this really killer app, but it's platform-dependent upon OSX. Drew is making progress on his Visual C++ Windows app, but that's another app limited to one OS. How can we take all of these individual contributions and make them into something everyone can use and enjoy? we can host it on muzscman.com
 |
|
  yock TFTC Premium join:2000-11-21 Fairfield, OH
| reply to Johnny This is the mental process I went through when I wanted to build the web application that handled it all. Gomez put together a data model and some templates for code generation but I just didn't have the time or the knowledge to contribute interface code.
You now have this really killer app, but it's platform-dependent upon OSX. Drew is making progress on his Visual C++ Windows app, but that's another app limited to one OS. How can we take all of these individual contributions and make them into something everyone can use and enjoy? |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs:
·wavebroadband
| reply to Johnny said by Johnny :1) See if Chip already holds a current vote on somebody - i.e. the value of his VotedFor key is non-blank. I can't believe I didn't think of that. Right now I loop through ALL player's VotedBy arrays and check for the name. LOL.
I'm going to have to work in the setups with roles and night actions, but it's always a motivation/time thing. I'm getting .NET 2008 Express installed on the laptop and am going to be taking that to work  |
|
  Johnny Premium join:2001-06-27 Atlanta, GA
·Comcast
| reply to drew Yep - Here's my pseudocode for Vote:
Given player "Chip" who wants to vote for "Dale":
1) See if Chip already holds a current vote on somebody - i.e. the value of his VotedFor key is non-blank. 2) If so, see if the player currently voted for is Dale. If so, just return - do nothing. 3) If not Dale, then call Unvote: to unvote whomever Chip's current vote is. 4) Insert Dale as Chip's current voted player. 5) Call the routine to re-calculate the list of voters for each player. Dale's list will thus include Chip, and whomever Chip had previously had a vote on will have Chip removed from their list. This routine also stores the count of votes for each player as it makes the list. 6) Call checkForTwilight to see if Chip's vote was the hammer. If so, see if the hammer caused a win situation. Otherwise call setPostText with the "lynch" boolean set to True. This will cause the setPostText method to remove the lynched player, zero the votes, turn off the Vote and Unvote buttons and enable the Night Action buttons.
If the lynched player was a Doc, a Cop, or a Roleblocker, then their respective boolean is set to "dead" so their Night Action will not be enabled.
After the user sets the night action popups for those night actors that are still alive, the Daybreak button carries out the night actions, checks for game over and lynch-or-lose, records the Cop's findings for the log, and turns on the Vote and Unvote buttons and turns off the Night Action buttons, once again setting "dead" for a night actor who was whacked.
The code never interacts with the UI widgets directly - they are all set to observe the booleans and automatically change their states when the booleans change. (Cocoa Bindings). They also automatically set variables in the code when their setting is changed by the user. |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs:
·wavebroadband
1 edit | reply to Johnny The unvote was actually my favorite part of the whole thing. That one really taxed my thinking, which is exactly why I did it first. I figured if I could get past it, it'd be fine.
The key was using the String.Split method. To explain it: "VotedBy" is a column in the database and could contain a string like "drew, Johnny, yock, Muzscman". Using the .Split, I would have an array of strings, in this case the array would contain: "drew", "", "Johnny", "", "yock", "", "Muzscman". I got hung up on the null strings until I realized I was already doing a string compare against the array at index "i" so to speak. So I just added in a condition to the logic to ignore null strings ;)
Oh, and I here I'm going to RAVE about the way Visual Studio handles Data Connections. It's a bit complicated at first, and caused me to give up quite early into the project until I realized there was a local data problem (the table was being over written each time by the nature of a couple settings). However, using the "TableAdapter", I am able to define SQL Queries and then just use them like they're a function of that adapter. You'll see the most used thing in there is "MafiaTableAdapter.GetVotedBy(lbVotee.Text). That is just the quick and dirty way of running the following SQL, which is something I only had to define once: The "@Votee" is the variable I stuff in there and have it evaluate. It's no where near a complicated SQL, but I only had to write it once and then I could just call it. I have no idea if this was something that's been around for years, as this is my first application non-work related in a non-dead language that touched any kind of DB. I thought it was the cat's meow. |
|
  Johnny Premium join:2001-06-27 Atlanta, GA
·Comcast
| reply to yock Well, the only thing mine needs now is to automate the screen-scraping to collect the votes and unvotes from the thread.
I predicted a couple of years ago that the read-only nature of web pages was going to be a huge problem when someone wanted to control them, as there is no API and no way to manipulate them programmatically. There's not even a way to send a "next page" to get to the next page of a multi-page thread.
Every site is custom in where the next page buttons are, where the indication of what the current page is, etc.
I'm not talking about modifying the pages - simply automating the navigation that the user would do when reading the pages. It's a mess, as there is absolutely no standard and no API.
We could kludge up some incredibly complex and ball-of-spaghetti thing that tried to read a thread and extract the votes and unvotes, but it would:
1) Be specific to this site 2) Still be heuristic to some degree, as people misspell player names 3) Have to somehow discover the setting for posts per page 4) Include some incredibly complex mess for identifying quoted vote text and not counting that, and that quoted text could be an arbitrary number of levels deep 5) Accept numerous variants on the vote text, such as with/without colon 6) Recognize that text such as "You asshole, I said I was not going to vote yock because he's innocent", all in bold, was not a vote
We need an API so we can send HTML to the site to go to the next page of a thread (or better, get a reference to the whole thread as one stream of text), get the number of posts per page, and find text on the pages. Otherwise, trying to screen-scrape this is an exercise in futility.
Automatic night actions are working in my app, although trying to generalize that to large closed games is a big undertaking. Right now all I handle is Cop, Doc, Mafia and Mafia Roleblocker. And even those have to be entered by hand after reading a PM - that too could be automated by having the app receive emails or some similar mechanism.
Roles are automatically generated, but again there is no clean way to send the PMs automatically, as there is no API for the website.
There is also no way to post the vote counts automatically, without resorting to some kludge where you try and click the "Reply" button by UI scripting and then send some tabs and then send a Paste and then click the Post button. And you'd have to read the titles of the pages that loaded to make sure you accommodate network delays and didn't try and send something to a page that had not loaded yet.
There is just no way to control reading and posting to a web site programmatically. I was always amazed that this wasn't thought of.
It's not a security issue, because flood control and login credentials take care of people trying to automate too much.
Then there is the interest factor - for example, just as I finished my C9 recorder, we started playing F11. So I added F11, and then we started playing random deadlines. So I added that, and now all the C9 code is obsolete.
I think a good, general-purpose Moderator Assistant would have to not even try to do screen-scraping or posting or even night actions. Doing night actions on 20 roles that the app had not ever heard of.... LOL. |
|
  yock TFTC Premium join:2000-11-21 Fairfield, OH | reply to Johnny Incidentally, when Drew got in touch with me last night I was deep into my long-awaited Java port. I've been talking to a friend of mine about some architecture concepts and, as usual, my concept has exploded into a lot more. |
|
  Johnny Premium join:2001-06-27 Atlanta, GA
·Comcast
| reply to drew Excellent.
That Unvote is a bitch, eh?
Glad to see a Windows build.
I considered Core Data and MySQL backend on mine but thought it was overkill. It probably would have simplified the persistent storage though.
By far the most tedious part was making sure the user could quit at any point and be returned to where they were when they quit. |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs:
·wavebroadband
2 edits | reply to drew Success!
After that screenshot and a quick chat with yock, I decided that having the application depend on SQL Server Express 2005 was a bit much. So, after trying unsuccessfully to port the database to Access, I tried SQL Compact 3.5. The .dll's come with the application.
The only downside to this application is that it requires .NET 3.5 Framework to run, which is something I'm OK with.
If you're interested, let me know and I'll be happy to share it with you!
Edit: (man, I think this is the first time I've edited a post in this forum )
»www.wundervoll.us/mafiavc/mafiavc.zip. It's right about 1MB in size. It was written in VB.NET on Visual Studio 2008. It requires .NET 3.5 Framework and the installer -should- let you know and help you download it if you don't have it. Feedback is much appreciated. |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs:
·wavebroadband
| reply to muzscman
 My creation |
Here's what I've spent the past two days of free time on. |
|
  Rook008 Miles To Go
join:2002-02-05 Far Rockaway, NY | reply to muzscman I like Option #. |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs: | reply to muzscman Wow, that's a lot of games.
I will say something though. We need to get people more active in the games. Johnny's F11 Short Time game is being eaten alive right now due to inactive players. |
|
  muzscman Mr. President Premium,VIP join:2002-02-15 Florissant, MO clubs:
·AT&T U-Verse
| reply to drew said by drew :I can tell you that trying to use the bold tags and all that jazz is hard for me. It's SO complicated to look at when quoting. lol after modding 30-40 games (has it really been that many??) you get used to it... |
|
  drew Reformation Premium join:2002-07-10 Port Orchard, WA clubs: | reply to muzscman I can tell you that trying to use the bold tags and all that jazz is hard for me. It's SO complicated to look at when quoting. |
|