[gnome-games/applygsoc2009: 69/76] -- Ask receiver before open the network game
- From: Pablo Castellano <pablog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/applygsoc2009: 69/76] -- Ask receiver before open the network game
- Date: Mon, 6 Sep 2010 02:53:01 +0000 (UTC)
commit f3bd302801abcea8c90acbcb2b792a568734f6b7
Author: Pablo Castellano <pablog src gnome org>
Date: Wed Sep 1 05:22:42 2010 +0200
-- Ask receiver before open the network game
* Also ship the puzzle together with the tube offer, instead of querying
afterwards.
* Need to let the initiator be blocked until receiver has agreed.
gnome-sudoku/src/lib/gnome_sudoku.py | 2 +-
gnome-sudoku/src/lib/main.py | 21 ++++++++++++++-------
2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/gnome_sudoku.py b/gnome-sudoku/src/lib/gnome_sudoku.py
index 65632bd..768d2e1 100644
--- a/gnome-sudoku/src/lib/gnome_sudoku.py
+++ b/gnome-sudoku/src/lib/gnome_sudoku.py
@@ -34,7 +34,7 @@ def start_game ():
parser = optparse.OptionParser(
version = defaults.VERSION,
option_list = [
- optparse.make_option("-v", const=True, action="store_const",
+ optparse.make_option("-d", const=True, action="store_const",
dest="debug", help="Print debug information",
default=False),
optparse.make_option("-p", const=True, action="store_const",
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 1a4c4f0..1ad033d 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -109,17 +109,24 @@ class SudokuGame (gconf_wrapper.GConfWrapper):
def _auto_load_new(self):
"""Automatically open a new game"""
- # TODO should use preconfigured level
- level = self.gconf['game-level']
- new_puzzle = self.sudoku_maker.get_puzzles(1, [level])
+ new_puzzle = self._generate_new_puzzle()
if new_puzzle:
- # get_puzzles returns a list of (<puzzle>, <difficulty>)
- logger.debug("%s game generated" % level)
- return new_puzzle[0][0]
+ return new_puzzle
else:
- logger.warning("failed to genereate new puzzle")
+ logger.error("failed to genereate new puzzle")
return None
+ def _generate_new_puzzle(self):
+ # TODO should use preconfigured or user-selected level
+ level = self.gconf['game-level']
+ # new_puzzle is a list, with the form of (<puzzle>, <difficulty>)
+ puzzles = self.sudoku_maker.get_puzzles(1, [level])
+ if puzzles:
+ puzzle = puzzles[0][0].replace(" ", "") # delete all spaces
+ logger.debug("%s game generated: %s" % (level, puzzle))
+ return puzzle
+ return None
+
def _open_game(self, game_type, puzzle):
"""Finally enter the puzzle"""
self._puzzle = puzzle
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]