mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-25 21:59:30 +01:00
- wxwin/mainframe.cc: Fixed a crash occurring when no config file is found
- Fixed a bug occurring in duplicate mode: sometimes the game ended too early, while it was still allowed to go on. Also updated the corresponding regression scenario
This commit is contained in:
parent
81e980104f
commit
7e7f7f2dfa
3 changed files with 52 additions and 50 deletions
|
@ -336,16 +336,36 @@ int Game::helperSetRackRandom(unsigned int p, bool iCheck, set_rack_mode mode)
|
|||
}
|
||||
}
|
||||
|
||||
// Count the needed consonants and vowels in the rack
|
||||
// (i.e. minimum required, minus what we already have in the rack)
|
||||
unsigned int neededVowels = min;
|
||||
unsigned int neededConsonants = min;
|
||||
for (unsigned int i = 0; i < tiles.size(); ++i)
|
||||
{
|
||||
if (neededVowels > 0 && tiles[i].isVowel())
|
||||
neededVowels--;
|
||||
if (neededConsonants > 0 && tiles[i].isConsonant())
|
||||
neededConsonants--;
|
||||
}
|
||||
|
||||
// Nothing in the rack, nothing in the bag --> end of the (free)game
|
||||
if (bag.getNbTiles() == 0 && pld.getNbTiles() == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check whether it is possible to complete the rack properly
|
||||
if (bag.getNbVowels() < neededVowels ||
|
||||
bag.getNbConsonants() < neededConsonants)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
// End of game condition
|
||||
if (iCheck)
|
||||
{
|
||||
if (bag.getNbVowels() == 0 || bag.getNbConsonants() == 0 ||
|
||||
bag.getNbTiles() == 1)
|
||||
if (bag.getNbVowels() < neededVowels ||
|
||||
bag.getNbConsonants() < neededConsonants ||
|
||||
(bag.getNbTiles() + tiles.size()) == 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -383,25 +403,6 @@ int Game::helperSetRackRandom(unsigned int p, bool iCheck, set_rack_mode mode)
|
|||
if (jokerAdded)
|
||||
pld.addNew(Tile::Joker());
|
||||
|
||||
// Count the needed consonants and vowels in the rack
|
||||
// (i.e. minimum required, minus what we already have in the rack)
|
||||
unsigned int neededVowels = min;
|
||||
unsigned int neededConsonants = min;
|
||||
for (unsigned int i = 0; i < tiles.size(); ++i)
|
||||
{
|
||||
if (neededVowels > 0 && tiles[i].isVowel())
|
||||
neededVowels--;
|
||||
if (neededConsonants > 0 && tiles[i].isConsonant())
|
||||
neededConsonants--;
|
||||
}
|
||||
|
||||
// Check whether it is possible to complete the rack properly
|
||||
if (bag.getNbVowels() < neededVowels ||
|
||||
bag.getNbConsonants() < neededConsonants)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// RACK_SIZE - tiles.size() is the number of letters to add to the rack
|
||||
if (neededVowels > RACK_SIZE - tiles.size() ||
|
||||
neededConsonants > RACK_SIZE - tiles.size())
|
||||
|
|
|
@ -3,14 +3,14 @@ commande> d 0 2
|
|||
mode duplicate
|
||||
[?] pour l'aide
|
||||
commande> a S
|
||||
Joueur 0: 918
|
||||
Joueur 1: 918
|
||||
Joueur 0: 931
|
||||
Joueur 1: 931
|
||||
commande> a T
|
||||
Joueur 0: DQRU
|
||||
Joueur 1: DQRU
|
||||
Joueur 0: R
|
||||
Joueur 1: R
|
||||
commande> a l
|
||||
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ?
|
||||
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
|
||||
commande> a p
|
||||
Eliot 1.5
|
||||
|
||||
|
@ -42,11 +42,12 @@ Player 1: Computer
|
|||
20 | TOEHLRT | PHOT | 8L | 27 | 0 |
|
||||
21 | ELRT+NME | REMELENT | C2 | 70 | 0 | *
|
||||
22 | QDRMUTI | MITAN | 5E | 20 | 0 |
|
||||
23 | DQRU | QUID | 13H | 13 | 0 |
|
||||
|
||||
Total: 918
|
||||
Total: 931
|
||||
|
||||
Rack 0: DQRU
|
||||
Rack 1: DQRU
|
||||
Rack 0: R
|
||||
Rack 1: R
|
||||
commande> a g
|
||||
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
A - - - - - - - - - - - H A V A
|
||||
|
@ -56,10 +57,10 @@ commande> a g
|
|||
E - - - - M - R - L - E - - - -
|
||||
F - - - - I C I - O K A - - - -
|
||||
G - - - - T U S - P I N - - - -
|
||||
H - - - F A B A c E E S - - - -
|
||||
I - - V I N E S - - F - - - - -
|
||||
H - - - F A B A c E E S - Q - -
|
||||
I - - V I N E S - - F - - U - -
|
||||
J - W A X - B - - - S E R I N S
|
||||
K D U N E - E - - - - - - - - T
|
||||
K D U N E - E - - - - - - D - T
|
||||
L O - - E - S E P T I m E - - Y
|
||||
M U - - - - - - H - - - - - - L
|
||||
N M O L L I T - O - C A R G U E
|
||||
|
|
|
@ -178,24 +178,6 @@ MainFrame::MainFrame(wxPoint __UNUSED__ pos_, wxSize size_)
|
|||
listsizer->Add(reslist, 1, wxEXPAND | wxLEFT | wxRIGHT, 1);
|
||||
#endif
|
||||
|
||||
wxString dicpath = config.getDicPath();
|
||||
try
|
||||
{
|
||||
Dictionary *dic = new Dictionary(dicpath.mb_str().data());
|
||||
m_dic = dic;
|
||||
m_game = GameFactory::Instance()->createTraining(*m_dic);
|
||||
if (m_game)
|
||||
{
|
||||
m_game->start();
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
wxCommandEvent event;
|
||||
// This will also start a new training game indirectly
|
||||
OnMenuConfGameDic(event);
|
||||
}
|
||||
|
||||
InitMenu();
|
||||
|
||||
statusbar = CreateStatusBar(2, 0, Status_ID);
|
||||
|
@ -239,6 +221,24 @@ MainFrame::MainFrame(wxPoint __UNUSED__ pos_, wxSize size_)
|
|||
SetClientSize(size_);
|
||||
Move(config.getFramePos(wxT(APPNAME)));
|
||||
|
||||
wxString dicpath = config.getDicPath();
|
||||
try
|
||||
{
|
||||
Dictionary *dic = new Dictionary(dicpath.mb_str().data());
|
||||
m_dic = dic;
|
||||
m_game = GameFactory::Instance()->createTraining(*m_dic);
|
||||
if (m_game)
|
||||
{
|
||||
m_game->start();
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
wxCommandEvent event;
|
||||
// This will also start a new training game indirectly
|
||||
OnMenuConfGameDic(event);
|
||||
}
|
||||
|
||||
InitFrames();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue