31 Commits

Author SHA1 Message Date
Mike Mueller
d3945ea763 Attempt to refactor text messages.
Worddle has a lot of logic dedicated to formatting text, and it makes the
code a little unreadable.  I tried to move most of the format strings out
as constants (and color them once instead of every time).  The resulting
code is a little cleaner looking, but I'm not sure I love it.
2012-04-04 01:52:38 -07:00
Mike Mueller
1b1b5331ea Inform late joiners of time left.
When you join late, you find out exactly how many seconds you have left
in the game.
2012-04-04 00:21:03 -07:00
Mike Mueller
79082016ef Implement "official" scoring mechanism.
Word values are now:

  Length | Points
  -------+--------
   3, 4  | 1
   5     | 2
   6     | 3
   7     | 5
   8+    | 11
2012-04-03 17:03:16 -07:00
Mike Mueller
4d5c9e4d2c Add 'start' and 'stop' Worddle commands.
Default is "start" so you can still just say "@worddle" to start a game.
"worddle stop" is the same as saying "@wordquit".
2012-04-03 17:01:34 -07:00
Mike Mueller
bffa11361a Fix Worddle to handle simultaneous games.
It was using the string 'worddle' as the unique identifier in all
scheduled events, which meant that a second game (in another channel,
at the same time) will erase the first game's scheduled events.

Now use the Worddle object's unique identifier when scheduling events.
2012-04-02 01:11:14 -07:00
Mike Mueller
78cef6b7a6 Clean up plugin shutdown logic.
Worked around a supybot bug and abstracted shutdown to calling
game.stop(now=True).  This way the Wordgames class can be ignorant
of the details of stopping a game.
2012-04-02 01:05:06 -07:00
Mike Mueller
21699c34c3 Relay pre-game taunts between players.
Anything typed before "Get Ready!" will be sent to other players.
2012-03-28 23:31:59 -07:00
Mike Mueller
25d750135c Support Freenode's TARGMAX value. 2012-03-28 23:16:17 -07:00
Mike Mueller
1462efce5f Fix bug showing Qu in 4th column.
If Q was the last letter in a row, it Was showing just 'Q' since the 'Q '
substring wasn't found.
2012-03-28 22:45:15 -07:00
Mike Mueller
7f721e7fb9 Tune pre-game timing.
* Whenever someone joins, put at least 5 seconds on the pre-game clock.
  (If more than 5 seconds are already remaining, do nothing.)
* Use the entire delay period before showing "Get ready!".
* Delay 3 more seconds before jumping into the game.
2012-03-28 00:42:28 -07:00
Mike Mueller
8f7016f28e Factor out Worddle results into class.
Also, results are now presented in descending order by score.
2012-03-28 00:30:44 -07:00
Mike Mueller
b489a4752b Only allow join if a game is running. 2012-03-27 22:57:54 -07:00
Mike Mueller
2fb7a3954b Fix regression in WordChain games.
Somehow I took out the code that handles public messages during a game.
2012-03-27 01:46:44 -07:00
Mike Mueller
e63a36b2c1 Turn debug mode off.
Did't mean to leave this on.
2012-03-27 01:39:55 -07:00
Mike Mueller
94ec34d5a6 General improvements to Worddle gameplay.
Added support for broadcasting messages in one shot if the IRC server
supports multiple targets. (Inspircd only right now, need to add support for
more servers.)  This will hopefully reduce flood issues and latency.

Cleaned up messages, improved use of color, added join notifications,
added a 'get ready' state 5 seconds before game starts.

Some code cleanup and refactoring.
2012-03-27 01:16:34 -07:00
Mike Mueller
353b5109dc Add a new game: Worddle
This is a clone of a famous game involving a 4x4 grid of random letters.
It uses Plugin's inFilter to filter out private messages to the bot during
the game, so that they are not treated as commands.  You can still send
commands to the bot using the command character during this period.  When
the game ends, the filter puts things back to normal.

Also implemented a new command when DEBUG is True, wordsolve, which shows
the solution to the current wordgame.
2012-03-26 16:39:37 -07:00
Mike Mueller
4bc4c0d858 Make _start_game arguments generic.
It shouldn't need to know what specific parameters the game will take.
(And its "length" parameter was out of date since the games currently
use "difficulty".)
2012-03-24 15:20:03 -07:00
Mike Mueller
d820ab1f1c Remove some useless checks.
Some solution length logic was previously moved to handle_message.  Some of
the code in _valid_solution became nonsensical (not broken, just weird).

Cleaned up.
2012-03-04 22:57:10 -08:00
Mike Mueller
b69967628a Change default dictionary and improve configurability.
Now defaults to the /usr/share/dict/american-english dictionary which is
probably found on many Linux systems today (avoiding the need to dig up a word
file on the interwebs).  On Debian/Ubuntu, you can 'apt-get install wamerican'.

Added a configurable regexp to filter the word list down to reasonable words.
Defaults to allow lowercase a-z only, therefore filtering out proper names,
hyphenations, contractions, and words with accented characters like "adiós".
(But hopefully still supporting non-English users by allowing this to be
changed.)
2012-03-04 13:46:46 -08:00
Mike Mueller
82e4665a82 Minor wording fix. 2012-03-03 14:42:58 -08:00
Mike Mueller
029ba10906 Oops, handle missing word file gracefully.
Apparently I backed out the previous change that handled this.
2012-03-03 14:41:00 -08:00
Mike Mueller
844723d28a Filter duplicate words in puzzles.
Was occasionally generating a puzzle foo > --- > --- > foo.  Oops.
2012-03-02 17:23:31 -08:00
Mike Mueller
a443d66473 Fix a performance issue in _find_solutions.
WordTwist successors can take you in circles (scare > stare > scare),
so check for this condition to avoid generating overly many potential
solutions.
2012-03-02 17:04:21 -08:00
Mike Mueller
17d1f91f8c Revise game difficulty settings.
Instead of taking lengths, the games now take easy|medium|hard|evil.
These values correspond to a range of puzzle lengths, word lengths, and
number of possible solutions.  I attempted to tune them to reasonable
values, but I could see them changing.

Also did a little more code clean-up.
2012-03-02 16:46:54 -08:00
Mike Mueller
b519259f54 Update copyright information. 2012-03-02 15:25:44 -08:00
Mike Mueller
51ca3bedfd Improve WordShrink's is_trivial definition.
No substrings should occur in any word of any solution (not just two
successive words).  This is really going to narrow down the set of puzzles,
hopefully it doesn't churn or get repetitive.
2012-02-24 20:18:36 -08:00
Mike Mueller
5e570f61c1 Refactor, optimize, clean-up.
The two games have a lot in common, so factored out a base class called
WordChain that implements most of the logic.  The game-specific behaviors
are implemented in the (now smaller) WordTwist and WordShrink classes.

Optimized to build a map of word relationships first and then derive all game
behavior from that map.  This could probably be improved even more, but for
the moment it is working nicely.
2012-02-24 19:17:05 -08:00
Mike Mueller
25136ae926 Fix a bug in error reporting. 2012-02-24 01:04:10 -08:00
Mike Mueller
e74ca803fe Restrict input snarfing a bit.
Only attempt to validate responses that look like words.
2012-02-24 00:33:14 -08:00
Mike Mueller
180252e826 Handle missing wordfile gracefully. 2012-02-24 03:21:45 -05:00
Mike Mueller
4afb3cbe3e Initial commit! 2012-02-24 00:10:33 -08:00