diff options
Diffstat (limited to 'ksirtet')
32 files changed, 1726 insertions, 0 deletions
diff --git a/ksirtet/CHANGELOG b/ksirtet/CHANGELOG new file mode 100644 index 00000000..925a24d9 --- /dev/null +++ b/ksirtet/CHANGELOG @@ -0,0 +1,301 @@ +2.1.11b (1 September 2005) [KDE 3.4.3 stable] + * fix compilation dependencies + * "fix" bug #65488 by disabling network games + +2.1.11 (12 September 2004) [KDE 3.3.1 stable] + * fix loss of key down action after switching windows (bug #86017) + * fix removed lines being not updated at restart (bug #88990) + +2.1.10 (4 July 2004) [KDE 3.3 stable] + * use zoom in/out actions (bug #65478) + * remove arrows in two players mode + add description for the three + balls in multiplayer game (bug #65489) + +2.1.9 (31 May 2004) + * more detailed removed line display + * display level in progress bar + +2.1.8 (10 March 2004) [KDE 3.2.2 stable] + * fix bug #65490 (default with simpler removed lines display) + * fix bug #77170 (crash at startup) + +2.1.7 (24 January 2003) [KDE 3.2 stable] + * more control on drop down action by key press and release + * move to left/right column actions + * notifications + * fix crash when switching from normal to arcade game + * options for old style rotation, for direct drop down and for + simplified "removed blocks" display[idea by Whitehawk Stormchaser] + * next/previous player names removed: it was confusing imho + * clean up configuration dialog GUI + * better multiplayer highscores dialog + * removed "start" button for clients + +2.1.6b (18 December 2002) [KDE 3.1 stable] + * fix stage display + +2.1.6 (6 June 2002) + * simplify start/pause button (ugly with large texts) + * arcade mode (only 6 levels) for KSirtet [idea by Douglas Smith] + * KAccel is not used anymore... + * some code cleanup and separation of source directories + +2.1.5 (16 April 2002) + * highlight level lcd when it changes + * progress bar for level [idea by Niko Boehm] + +2.1.4c (13 May 2002) + * fix crash when pause pressed during animation [report by Christian Esken] + +2.1.4b (15 April 2002) [KDE 3.0.1 stable] + * fix background color (less flicker and no more white background for + not compliant (?) window manager) [report by Niko Boehm] + * fix T piece rotation [report by Niko Boehm] + * save key shortcuts [report by Niko Boehm] + +2.1.4 (15 January 2002) + * revamped settings + * some cleanups + * fix several problems in AI code : much better now (for ksirtet) + * several bug fixes + * fix piece rotation in ksirtet and kfouleggs [many thanks to Sebastian + Boehm] + +2.1.3 (16 December 2001) + * use the dynamic library for highscores and the new API + * fix a severe bug occurring for multiple gifts (multiplayers game in ksirtet) + * reset gifts at game start (multiplayers game) + * slow down the computer player (for ksirtet) + * fix AI configuration saving + +2.1.2 (29 November 2001) + * fix pause behaviour in menu (forward port from 2.2 branch) + * use KConfigGroupSaver everywhere + * World-wide highscores for KSirtet and KFoulEggs !! + +2.1.1 (17 October 2001) + * some more reorganization + * some code revamped and simplified + * a DESIGN file ! + * progressive fall animation added to kfouleggs + * board can be made transparent :) + * "removed" lcd now displays more details (ksirtet & kfouleggs) + * highscores updated (new dialog) + * ported to Qt 3.0 (a piece of cake :) + +2.1.0b (28 November 2001) [SF 2.2 stable] + * fix pause behaviour in menu [bug reported by Erik Hill] + +2.1.0 (17 July 2001) [KDE 2.2 stable] + +2.0.10 (03 July 2001) [SF 2.2 devel] + * reorganized sources files + * fixed level increase with initial level higher than 1 [thanks to Christof + Musik] + +2.0.9 (24 May 2001) + * configuration of the initial level added [suggested by Alain Beyrand among + others ...] + * enhancement of highscores : nicer dialogs, nb of games, mean score, ... + * use of KHighscore + * use of KStdGameAction + * fix shadow display + +2.0.8 (11 April 2001) + * fix for multiplayers game (see lib changelog) + * pause when highscores requested [suggested by David Grill Watson] + * create GenericBoard class (for future extensions) + +2.0.7 (14 March 2001) + * changed highscores accelerator to CTRL + H (more standard) + * better use of session-management + +2.0.6 (1 February 2001) [KDE 2.1 stable] + * more explanations in KFouleggs score computation. + * some fix in KFoulEggs piece drawing [I was not able to see + the problem ; thanks to Tom Colgate] + +2.0.5 (13 September 2000) [KDE 2.0 stable] + * fix for change of behaviour in QCanvas (QCanvasItems need a show). + +2.0.4 (4 September 2000) + * fixed behaviour of button in highscores dialog when entering the winner + name [proposed by Lotta Inkovaara] + * fixed repaint problems of piece shadow [some flicker added though] + * keys bindings should be now saved [due to some obscure bug in + kdelibs/kaccel ; thanks to Chris] + +2.0.3 + * use of KMainWindow + interception of LayoutHint events to fix the resize + problems ... + +2.0.2 (19 June 2000) + * versioning the XMLGUI files + * removed (unstandard) title in dialogs + * block size is configurable + +2.0.1 (28 May 2000) + * fixed highscores dialog showing empty if score too small [bug reported + by David Grill Watson] + * fixed something in the XML files ... + +2.0.0 (10 May 2000) + * stupid bug fixed (off by one error in random piece generation) + * fix segfault when exiting with the close button + +1.1.16 (14 April 2000) + * AI is now configurable + * multiplayer + AI for fouleggs !! + * XMLguified + config cleaned up + * animations can be configured on/off + +1.1.15 (3 April 2000) + * nicer "light removed" animation in ksirtet + * new "bump falling piece" animation + * new "progressive falling on remove" animation for ksirtet + +1.1.14 (2 April 2000) + * KAction + * separated in two executables (ksirtet and kfouleggs) + * use of QCanvas done + * fixed a nasty bug for kfouleggs (segfault when the piece is almost at top + and the action dropDown is activated) + +1.1.13 (7 February 2000) + * found bug in piece copying/random generation + * KAboutData + * first modifications for the use of QCanvas + +1.1.12 (14 December 1999) + * FE drawings are ok (not very cute though) + * multiplayers status line completed : players names + gift leds + * T piece starting orientation modified so it can be rotated immediately + (this is of some importance for the AI player ...) + * LCD style slightly changed + * AI customization (to optimize AI ...) [uncomplete] + * "What's This" added + * multiplayers score dialog [uncomplete] + +1.1.11 (8 November 1999) + * keys were "inverted" for two-players-game. + * Foul Eggs game !! (score + multiplayers + AI still to be done). + +1.1.10 (14 August 1999) + * big change for multiplayers game (due to heavy modification of lib) + +1.1.9 (6 July 1999) + * highscore dialog is "layouted" + * layout fixes + +1.1.8 + * fixes in AI and gift mechanism. + * gift received and gift sent shower in multiplayers game. + +1.1.7 (21 March 1999) + * "shadow" and "show next" are configurable via menu. + * fix in shadow repaint. + * fix : the removed line display is now cleaned when starting a new game. + +1.1.6 (20 March 1999) + * the main board now use QT's layout engine. + * some clean-ups for future extensions. + * asynchronous opponent gift treatement (no more funnies when gray lines + arrive at unexpected time) + * shadow of the falling piece (to limit parallax errors) ... + +1.1.5 (11 March 1999) + * fixed the layout code for Qt 2.0 (Mario Weilguni <mweilguni@kde.org>) + +1.1.4 (6 March 1999) + * you can play against the COMPUTER !!! well its brain is rather limited + but it's better than nothing :) + * changes all over the place. + +1.1.3 (6 March 1999) + * bug fix : random generation is uniform among games in multiplayers. + * bug fix : in multiplayer : dropdown state does not persist after gameover. + +1.1.2 (2 March 1999) + * big review of generic tetris code : + - three fixes : * the falling pieces are better centered. + * the next piece is shown well centered. + * at game over the next piece is effectively the + next one. + - preparation for future extensions. + +1.1.1 (28 February 1999) + * many bug fixes for multiplayer (there are still some nasty ones around) + +1.1.0 (25 February 1999) + * big revamping : the old net code is gone ... a new one is coming : + you can now play on the same computer ... the network code may (will ?) + crash : understand "highly experimental" ;) + * well it's almost ok. still some rough ends ... + +1.0.2 (18 February 1999) + * fix a focus bug (bug report by Malte Starostik) + +1.0.1 (16 February 1999) + * bug fix : no more funnies when pausing at unexpected moments [bug report by + Malte Starostik] + * keys settings were not saved [bug report by Sven Kuenzler] + * drop pieces were not giving points anymore (thought I had already + killed this one ...) + * more clean-up (ad nauseam) + +1.0.0 (19 June 1998) [KDE 1.0 stable] + * final cleanup before 1.0 ! + +0.2.12 (10 March 1998) + * some cleanups + * blink full lines + * accelerated drop for dropped down pieces + * one more time for ace players : the main score box was too small + +0.2.11 + * [Robert Williams] Added version.h and ChangeLog + * [Robert Williams] Added getCaption() + +0.2.10 + * included in the CVS tree + * KTopLevelWidget & KMenubar + +0.2.7 + * some cleanups + international support + * net fix : use 'uname' rather than 'getenv("HOSTNAME")' + +0.2.6 + * no more NULLs (for the sake of 64bits) + * a nicer highscores dialog (there should be no more truncated score + for ace players :) + +0.2.5 + * just a minor change to allow compile in Linux/Alpha + +0.2.4 + * minor changes + * "kexample 0.31" compliance + +0.2.3 + * adapted for libkdecore 0.7 + * hide/show menubar + popup menu (ala kvt) + * more compliant to the Style Guide + +0.2.2 + * use kdehelp + * use of KConfig and clean the highscore dialog + * use of kmsgbox for about :) [it is nice] + +0.2.1 + * use of KKeyCode for the management of keys + +0.2 + * many things : network game + extension for other similar game + +0.1 + * get rid of the grab stuff from the original version + * small reorganisation + * change of the key-bindings (cf help) + * [Asger] the real scoring + * [Asger] get rid of some needless stuff in GenericTetris + * highscores diff --git a/ksirtet/DESIGN b/ksirtet/DESIGN new file mode 100644 index 00000000..0cc7d3d2 --- /dev/null +++ b/ksirtet/DESIGN @@ -0,0 +1,57 @@ +'lo, time to explain how some things are designed in the generic class +of these games + +NB: You should read this file with a fixed font editor ... + +the following set of functions is implemented in the hierarchy of classes : +GenericTetris -> BaseBoard -> Board -> specific Board class for each game + +=============================================================================== +action 'Piece Drop Down' activated + | +pieceDropped() <-| + | | +oneLineDown() -> by timer -| + +=============================================================================== +if oneLineDown() make the piece touch the ground + | +pieceDropped() + | +_beforeGlue() <-| + | | +beforeGlue() -> by timer -| // here is implemented the bump effect + | (when done) +gluePiece() + | +_afterGlue() <-| + | | +afterGlue() -> by timer -| // here kfouleggs remove holes + | (when done) +needRemoving ? no -> _afterAfterRemove() + | +_beforeRemove() <-| + | | +beforeRemove() -> by timer -| // here blocks to be removed are highlighted + | (when done) +remove() + | +_afterRemove() <-| + | | +afterRemove() -> by timer -| // here is animated the fall of piece in + | // the holes leaved by removed blocks + | if needs removing again -> _beforeRemove() + | +_afterAfterRemove() ? no gift pending -> afterAfterRemove() + | +putGift() + | +_afterGift() <-| + | | +afterGift() -> by timer -| // here kfouleggs make the gift block to land + | +_afterAfterRemove() + | +afterAfterRemove() ? gameOver -> gameOver() + | +newPiece() diff --git a/ksirtet/LICENSE b/ksirtet/LICENSE new file mode 100644 index 00000000..4f0ca177 --- /dev/null +++ b/ksirtet/LICENSE @@ -0,0 +1,19 @@ +KSIRTET +------- +Copyright (c) 1995 Eirik ENG +Copyright (c) 1996-2004 Nicolas HADACEK (hadacek@kde.org) + + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/ksirtet/Makefile.am b/ksirtet/Makefile.am new file mode 100644 index 00000000..0d3fff71 --- /dev/null +++ b/ksirtet/Makefile.am @@ -0,0 +1,4 @@ +# Please keep ksirtet in a subdir from here. +# If moving it here, then cvs complains that ksirtet is both a local exe +# and a (deleted) cvs subdir +SUBDIRS = ksirtet diff --git a/ksirtet/README b/ksirtet/README new file mode 100644 index 00000000..c73d9a16 --- /dev/null +++ b/ksirtet/README @@ -0,0 +1,18 @@ +KSIRTET : a tetris-alike game +--------------------------------- +Copyright (c) 1995 Eirik ENG +Copyright (c) 1996-2004 Nicolas HADACEK (hadacek@kde.org) +Distributed under the GNU General Public License + +KSirtet is an adaptation of the well-known Tetris game. +It provides multiplayers functionality and "artificial +intelligence" player. + +The code links to the ksirtet libraries. + + +Note: the code is in the subdir "ksirtet" due to a CVS limitation known +as the "CVS memory effect" <grin> + + +Enjoy ! diff --git a/ksirtet/TODO b/ksirtet/TODO new file mode 100644 index 00000000..112cc096 --- /dev/null +++ b/ksirtet/TODO @@ -0,0 +1,8 @@ +see also the TODO for libksirtet + + * more varied AIs (it is now quite good) + + * action for "total drop", "to left", "to right", "half turn" + + * in multiplayer, when one player changes level: all players should go to + that level too (?) diff --git a/ksirtet/configure.in.in b/ksirtet/configure.in.in new file mode 100644 index 00000000..88bff352 --- /dev/null +++ b/ksirtet/configure.in.in @@ -0,0 +1,2 @@ +AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/select.h sys/filio.h) + diff --git a/ksirtet/ksirtet/Makefile.am b/ksirtet/ksirtet/Makefile.am new file mode 100644 index 00000000..2466e023 --- /dev/null +++ b/ksirtet/ksirtet/Makefile.am @@ -0,0 +1,81 @@ +INCLUDES = -I$(top_builddir)/libksirtet -I$(top_srcdir)/libksirtet -I$(top_srcdir)/libksirtet/base -I$(top_srcdir)/libkdegames -I$(top_srcdir)/libkdegames/highscore $(all_includes) + +KDE_CXXFLAGS = $(KDE_USE_FPIE) + +bin_PROGRAMS = ksirtet +ksirtet_LDADD = $(top_builddir)/libksirtet/common/libksirtetcommon.la +ksirtet_DEPENDENCIES = $(top_builddir)/libksirtet/common/libksirtetcommon.la +ksirtet_LDFLAGS = $(KDE_USE_PIE) $(all_libraries) $(KDE_RPATH) +ksirtet_SOURCES = piece.cpp board.cpp ai.cpp field.cpp settings.cpp main.cpp prefs.kcfgc +METASOURCES = board.moc ai.moc field.moc settings.moc main.moc + +rcdir = $(kde_datadir)/ksirtet +rc_DATA = ksirtetui.rc + +KDE_ICON = ksirtet + +xdg_apps_DATA = ksirtet.desktop +kde_kcfg_DATA = ksirtet.kcfg + +appdatadir = $(kde_datadir)/ksirtet +appdata_DATA = eventsrc + +messages: rc.cpp + $(XGETTEXT) rc.cpp $(ksirtet_SOURCES) -o $(podir)/ksirtet.pot + +check_PROGRAMS = check_score +check_score_SOURCES = check_score.cpp +check_score_LDADD = -lkdecore +check_score_LDFLAGS = $(all_libraries) $(KDE_RPATH) + +# for system-wide highscore file +DESTBIN = $(DESTDIR)$(bindir)/$(bin_PROGRAMS) +DESTHIGHSCORES = $(DESTDIR)$(HIGHSCORE_DIRECTORY) +DESTSCORES = $(DESTDIR)$(HIGHSCORE_DIRECTORY)/$(bin_PROGRAMS).scores + +install-data-local: + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && echo "********************************************************" \ + && echo "" \ + && echo "This game is installed sgid \"games\" to use the" \ + && echo "system-wide highscore file (in "$(HIGHSCORE_DIRECTORY)")." \ + && echo "" \ + && echo "If the system-wide highscore file does not exist, it is" \ + && echo "created with the correct ownership and permissions. See the" \ + && echo "INSTALL file in \"kdegames/libkdegames/highscore\" for details." \ + && echo "" \ + && echo "********************************************************" \ + ) || true + +install-exec-hook: + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((chown $(highscore_user):$(highscore_group) $(DESTBIN)) \ + || echo "Error: Could not install the game with correct permissions !!" \ + )) || true + + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((mkdir -p $(DESTHIGHSCORES) && chown $(highscore_user):$(highscore_group) $(DESTHIGHSCORES) \ + && chmod 750 $(DESTHIGHSCORES)) \ + || echo "Error: Could not create the highscore directory with correct permissions !!" \ + )) || true + + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((chown $(highscore_user):$(highscore_group) $(DESTBIN)) \ + || echo "Error: Could not install the game with correct permissions !!" \ + )) || true + + @(test ${setgid} = true \ + && ((chmod 2755 $(DESTBIN)) \ + || echo "Error: Could not install the game with correct permissions !!" \ + )) || true + + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((touch $(DESTSCORES) && chown $(highscore_user):$(highscore_group) $(DESTSCORES) \ + && chmod 0660 $(DESTSCORES)) \ + || echo "Error: Could not create system-wide highscore file with correct permissions !!" \ + )) || true + +field.o: ../../libksirtet/common/commonprefs.h ../../libksirtet/base/baseprefs.h +main.o: ../../libksirtet/common/commonprefs.h ../../libksirtet/base/baseprefs.h +prefs.o: ../../libksirtet/common/commonprefs.h ../../libksirtet/base/baseprefs.h + diff --git a/ksirtet/ksirtet/ai.cpp b/ksirtet/ksirtet/ai.cpp new file mode 100644 index 00000000..eba477d2 --- /dev/null +++ b/ksirtet/ksirtet/ai.cpp @@ -0,0 +1,25 @@ +#include "ai.h" +#include "ai.moc" + +#include <klocale.h> + + +const AI::Data KSAI::DATA[] = { + { "OccupiedLines", I18N_NOOP("Occupied lines:"), 0, + false, nbOccupiedLines }, + { "Holes", I18N_NOOP("Number of holes:"), 0, + false, nbHoles }, + { "Spaces", I18N_NOOP("Number of spaces:"), I18N_NOOP("Number of spaces under mean height"), + false, nbSpaces }, + { "Peak2Peak", I18N_NOOP("Peak-to-peak distance:"), 0, + false, peakToPeak }, + { "MeanHeight", I18N_NOOP("Mean height:"), 0, + false, mean }, + { "FullLines", I18N_NOOP("Number of full lines:"), 0, + true, nbRemoved }, + LastData +}; + +KSAI::KSAI() + : AI(0, 200, DATA) // #### tune or configure times... +{} diff --git a/ksirtet/ksirtet/ai.h b/ksirtet/ksirtet/ai.h new file mode 100644 index 00000000..465925ef --- /dev/null +++ b/ksirtet/ksirtet/ai.h @@ -0,0 +1,17 @@ +#ifndef KS_AI_H +#define KS_AI_H + +#include "common/ai.h" + + +class KSAI : public AI +{ + Q_OBJECT + public: + KSAI(); + + private: + static const Data DATA[]; +}; + +#endif diff --git a/ksirtet/ksirtet/board.cpp b/ksirtet/ksirtet/board.cpp new file mode 100644 index 00000000..4c084f63 --- /dev/null +++ b/ksirtet/ksirtet/board.cpp @@ -0,0 +1,181 @@ +#include "board.h" +#include "board.moc" + +#include "common/misc_ui.h" +#include "common/factory.h" +#include "piece.h" + + +using namespace KGrid2D; + +KSBoard::KSBoard(bool graphic, QWidget *parent) + : Board(graphic, new GiftPool(parent), parent), + filled(matrix().height()), linesRemoved(4) +{ + init(); +} + +void KSBoard::init() +{ + addRemoved = 0; + _lastRemoved = 0; + for (uint i=0; i<4; i++) { + linesRemoved[i] = 0; + _lastRemoved += 2<<i; // update + } +} + +void KSBoard::copy(const GenericTetris &g) +{ + Board::copy(g); + filled = static_cast<const KSBoard &>(g).filled.copy(); // deep copy +} + +void KSBoard::start(const GTInitData &data) +{ + init(); + Board::start(data); +} + +void KSBoard::computeInfos() +{ + Board::computeInfos(); + + filled.fill(0); + for (uint j=0; j<firstClearLine(); j++) + for (uint i=0; i<matrix().width(); i++) { + Coord c(i, j); + if ( matrix()[c] ) filled[j]++; + } +} + +bool KSBoard::needRemoving() +{ + for(uint j=0; j<firstClearLine(); j++) + if ( filled[j]==matrix().width() ) return true; + return false; +} + +bool KSBoard::toBeRemoved(const Coord &c) const +{ + return ( filled[c.second]==matrix().width() ); +} + +void KSBoard::remove() +{ + uint nbFullLines = 0; + for (uint k=0; k<firstClearLine(); k++) + if ( filled[k]==matrix().width() ) nbFullLines++; + + Board::remove(); + + linesRemoved[nbFullLines-1]++; + _lastRemoved = 2<<(nbFullLines-1); + addRemoved += nbFullLines; + updateRemoved(nbRemoved() + nbFullLines); + + if ( isArcade() ) return; + + // Assign score according to level and nb of full lines (gameboy style) + switch (nbFullLines) { + case 0: break; + case 1: updateScore( score() + 40 * level() ); break; + case 2: updateScore( score() + 100 * level() ); break; + case 3: updateScore( score() + 300 * level() ); break; + case 4: updateScore( score() + 1200 * level() ); break; + } + + updateLevel(); +} + +bool KSBoard::toFall(const Coord &c) const +{ + return ( filled[c.second-1]==0 ); +} + +//----------------------------------------------------------------------------- +// Multiplayers methods +uint KSBoard::gift() +{ + uint g = (addRemoved>1 ? addRemoved-1 : 0); + addRemoved = 0; + return g; +} + +void KSBoard::setGarbageBlock(const Coord &c) +{ + Block *gb = currentPiece()->garbageBlock(); + gb->sprite()->show(); + setBlock(c, gb); +} + +bool KSBoard::_putGift(uint nb) +{ + if ( nbClearLines()==0 ) return false; + + // lift all the cases of one line + // (nbClearLine!=0 --> firstClearLine!=height + for (uint j=firstClearLine(); j>0; j--) + for (uint i=0; i<matrix().width(); i++) { + Coord src(i, j-1); + Coord dest(i, j); + moveBlock(src, dest); + } + + // fill the emptied low line with garbage :) + uint _nb = nb; + uint i; + do { + i = randomGarbage.getLong(matrix().width()); + Coord c(i, 0); + if ( matrix()[c]!=0 ) continue; + setGarbageBlock(c); + _nb--; + } while ( _nb!=0 ); + + return true; +} + +bool KSBoard::putGift(uint nb) +{ + for (uint k=0; k<nb; k++) { + if ( !_putGift(matrix().width() - k - 1) ) return false; + computeInfos(); + } + return true; +} + + +//----------------------------------------------------------------------------- +const KSBoard::StageData KSBoard::STAGE_DATA[Nb_Stages] = { + { 4, 1, false, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, + { 10, 1, false, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, + { 20, 1, false, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, + + // 10 blocks on each sides + { 10, 2, true, {10, 0, 0, 0, 0, 0, 0, 0, 0, 10}}, + // 10 blocks height triangle + { 15, 2, true, { 0, 2, 4, 7, 10, 10, 7, 4, 2, 0}}, + // 10 blocks height opposed triangle + { 20, 2, true, {10, 7, 4, 2, 0, 0, 2, 4, 7, 10}} +}; + +uint KSBoard::normalTime() const +{ + if ( !isArcade() ) return Board::normalTime(); + return cfactory->cbi.baseTime / (1 + stageData().speed); +} + +void KSBoard::arcadePrepare() +{ + if ( !stageData().hasPattern ) return; + + for (uint i=0; i<Width; i++) { + Q_ASSERT( stageData().pattern[i]<=matrix().height() ); + for (uint j=0; j<stageData().pattern[i]; j++) + setGarbageBlock(Coord(i, j)); + } + main->update(); +} + + diff --git a/ksirtet/ksirtet/board.h b/ksirtet/ksirtet/board.h new file mode 100644 index 00000000..90b1c231 --- /dev/null +++ b/ksirtet/ksirtet/board.h @@ -0,0 +1,50 @@ +#ifndef KS_BOARD_H +#define KS_BOARD_H + +#include "common/board.h" + + +class KSBoard : public Board +{ + Q_OBJECT + public: + KSBoard(bool graphic, QWidget *parent); + void copy(const GenericTetris &); + + void start(const GTInitData &); + enum Constants { Width = 10, Nb_Stages = 6 }; + uint nbRemovedLines(uint i) const { return linesRemoved[i]; } + uint lastRemoved() const { return _lastRemoved; } + + private: + QMemArray<uint> filled; + QMemArray<uint> linesRemoved; + uint addRemoved; + uint _lastRemoved; + + struct StageData { + uint todo, speed; + bool hasPattern; + uint pattern[Width]; + }; + static const StageData STAGE_DATA[Nb_Stages]; + + void init(); + uint gift(); + bool putGift(uint nb); + bool _putGift(uint nb); + bool needRemoving(); + void remove(); + bool toBeRemoved(const KGrid2D::Coord &) const; + bool toFall(const KGrid2D::Coord &) const; + void computeInfos(); + void setGarbageBlock(const KGrid2D::Coord &); + + const StageData &stageData() const { return STAGE_DATA[arcadeStage()]; } + uint normalTime() const; + uint arcadeTodo() const { return stageData().todo; } + uint arcadeDone() const { return nbRemoved(); } + void arcadePrepare(); +}; + +#endif diff --git a/ksirtet/ksirtet/check_score.cpp b/ksirtet/ksirtet/check_score.cpp new file mode 100644 index 00000000..71cd53be --- /dev/null +++ b/ksirtet/ksirtet/check_score.cpp @@ -0,0 +1,59 @@ +#include <iostream.h> + +#include <kcmdlineargs.h> + + +int main(int argc, char **argv) +{ + // read argument + KCmdLineArgs::init(argc, argv, "check_score", 0, 0, true); + static KCmdLineOptions options[] = + { {"+file", "Count of removed lines", 0} }; + KCmdLineArgs::addCmdLineOptions(options); + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + if ( args->count()==0 ) KCmdLineArgs::usage(); + QString s = args->arg(0); + bool ok; + uint nb = s.toUInt(&ok); + if ( !ok ) qFatal("The argument is not an unsigned integer."); + + cout << "--------------" << endl; + + // constants + const uint width = 10; + const uint height = 22; + const uint nbLinesPerLevel = 10; + const uint blocksPerPiece = 4; + + // compute level + uint level = (nb / nbLinesPerLevel) + 1; + cout << "Level : " << level << endl << endl; + + // compute max score due to drop down + uint ddScore = + ((width*height) / blocksPerPiece) * height; // board full of pieces + ddScore += + ((nb * width) / blocksPerPiece) * height; // piece for removed lines + cout << "Max Score from drop down pieces : " << ddScore << endl; + + // compute max score due to removed lines + uint score = 0; + uint nb_tetris = 0; + while ( nb>=4 ) { + nb -= 4; + level = (nb / nbLinesPerLevel) + 1; + score += 1200 * level; + nb_tetris++; + } + if ( nb==3 ) score += 300; + else if ( nb==2 ) score += 100; + else if ( nb==1 ) score += 40; + cout << "Max score from removed lines : " << score << endl; + cout << "Max count of tetris : " << nb_tetris << endl; + + cout << endl; + cout << "Max score : " << ddScore + score << endl; + + cout << "--------------" << endl; + return 0; +} diff --git a/ksirtet/ksirtet/eventsrc b/ksirtet/ksirtet/eventsrc new file mode 100644 index 00000000..1b563e72 --- /dev/null +++ b/ksirtet/ksirtet/eventsrc @@ -0,0 +1,360 @@ +[!Global!] +IconName=ksirtet +Comment=KSirtet +Comment[be]=Сіртэтрыс +Comment[bn]=কে-সরিটটে +Comment[hi]=के-सिर्टेट +Comment[mk]=КСиртет +Comment[ne]=केडीई सरटेट +Comment[pl]=Sirtet (anagram) +Comment[sv]=Ksirtet +Comment[ta]=Kசர்டெட் +Comment[tg]=KСиртетрис +Comment[tr]=Tetris +Comment[zh_TW]=俄羅斯方塊 + +[removed] +Name=Line removed +Name[ar]=لقد أزيل الخط +Name[be]=Лінія выдаленая +Name[bg]=Премахната е линия +Name[bn]=লাইন সরিয়ে ফেলা হয়েছে +Name[br]=Linenn lemet +Name[bs]=Uklonjena linija +Name[ca]=Línia eliminada +Name[cs]=Odstraněn řádek +Name[cy]=Gwaredwyd llinell +Name[da]=Linje fjernet +Name[de]=Zeile entfernt +Name[el]=Γραμμή αφαιρέθηκε +Name[eo]=Linio forigita +Name[es]=Línea eliminada +Name[et]=Eemaldatud rida +Name[eu]=Lerroa kendu da +Name[fa]=خط حذف شد +Name[fi]=Rivi poistettu +Name[fr]=Ligne supprimée +Name[ga]=Líne bainte +Name[gl]=Liña eliminada +Name[he]=שורה הוסרה +Name[hi]=पंक्ति हटाए +Name[hr]=Uklonjena linija +Name[hu]=Sor eltávolítva +Name[is]=Lína fjarlægð +Name[it]=Riga rimossa +Name[ja]=線を消しました +Name[km]=បន្ទាត់ដែលបានយកចេញ +Name[lt]=Linija panaikinta +Name[lv]=Rinda noņemta +Name[mk]=Отстранета е линија +Name[nb]=Linje fjernet +Name[nds]=Reeg wegdaan +Name[ne]=रेखा हटाइयो +Name[nl]=Regel verwijderd +Name[nn]=Linje fjerna +Name[pa]=ਸਤਰ ਹਟਾਈ +Name[pl]=Linia usunięta +Name[pt]=Linha removida +Name[pt_BR]=Linha removida +Name[ro]=Linie eliminată +Name[ru]=Линия удалена +Name[se]=Linnjá lea eretváldon +Name[sk]=Čiara odstránená +Name[sl]=Vrstica odstranjena +Name[sr]=Уклоњена линија +Name[sr@Latn]=Uklonjena linija +Name[sv]=Rad borttagen +Name[ta]=கோடு நீக்கப்பட்டது +Name[tg]=Сатр хориҷ карда шуд +Name[tr]=Silinen Çizgiler +Name[uk]=Лінія видалена +Name[zh_CN]=消去的行数 +Name[zh_TW]=消去的行 +Comment=Line removed +Comment[ar]=لقد أزيل الخط +Comment[be]=Лінія выдаленая +Comment[bg]=Премахната е линия +Comment[bn]=লাইন সরিয়ে ফেলা হয়েছে +Comment[br]=Linenn lemet +Comment[bs]=Uklonjena linija +Comment[ca]=Línia eliminada +Comment[cs]=Odstraněn řádek +Comment[cy]=Gwaredwyd llinell +Comment[da]=Linje fjernet +Comment[de]=Zeile entfernt +Comment[el]=Γραμμή αφαιρέθηκε +Comment[eo]=Linio forigita +Comment[es]=Línea eliminada +Comment[et]=Eemaldatud rida +Comment[eu]=Lerroa kendu da +Comment[fa]=خط حذف شد +Comment[fi]=Rivi poistettu +Comment[fr]=Ligne supprimée +Comment[ga]=Líne bainte +Comment[gl]=Liña eliminada +Comment[he]=שורה הוסרה +Comment[hi]=पंक्ति हटाए +Comment[hr]=Uklonjena linija +Comment[hu]=Sor eltávolítva +Comment[is]=Lína fjarlægð +Comment[it]=Linea rimossa +Comment[ja]=線を消しました +Comment[km]=បន្ទាត់ដែលបានយកចេញ +Comment[lt]=Linija panaikinta +Comment[lv]=Rinda ir noņemta +Comment[mk]=Отстранета е линија +Comment[nb]=Linje fjernet +Comment[nds]=Reeg wegdaan +Comment[ne]=रेखा हटाइयो +Comment[nl]=Regel verwijderd +Comment[nn]=Linje fjerna +Comment[pa]=ਸਤਰ ਹਟਾਈ +Comment[pl]=Linia usunięta +Comment[pt]=Linha removida +Comment[pt_BR]=Linha removida +Comment[ro]=Linie eliminată +Comment[ru]=Линия удалена +Comment[se]=Linnjá lea eretváldon +Comment[sk]=Čiara odstránená +Comment[sl]=Odstranjena vrstica +Comment[sr]=Уклоњена линија +Comment[sr@Latn]=Uklonjena linija +Comment[sv]=Rad borttagen +Comment[ta]=கோடு நீக்கப்பட்டது +Comment[tg]=Сатр хориҷ карда шуд +Comment[tr]=Silinen çizgiler +Comment[uk]=Лінія видалена +Comment[zh_CN]=消去的行数 +Comment[zh_TW]=消去的行 +default_presentation=0 + +[game over] +Name=Game Over +Name[af]=Speletjie Bo +Name[ar]=اللعبة انتهت +Name[az]=Oyun Qurtardı +Name[be]=Канец гульні +Name[bg]=Край на играта +Name[bn]=খেল খতম +Name[br]=Echu an abadenn +Name[bs]=Igra završena +Name[ca]=Fi de la partida +Name[cs]=Konec hry +Name[cy]=Gêm Drosodd +Name[da]=Spillet forbi +Name[de]=Spiel beendet +Name[el]=Τέλος παιχνιδιού +Name[eo]=Ludo finita +Name[es]=Fin de la partida +Name[et]=Mäng läbi +Name[eu]=Jokoa amaitu da +Name[fa]=بازی تمام شد +Name[fi]=Peli loppu +Name[fr]=Fin de la partie +Name[ga]=Cluiche Thart +Name[gl]=Fin do Xogo +Name[he]=סיום משחק +Name[hi]=खेल ख़त्म +Name[hr]=Igra je završena +Name[hu]=Vége a játéknak +Name[id]=permainan berakhir +Name[is]=Leik lokið +Name[it]=Gioco terminato +Name[ja]=ゲームオーバー +Name[km]=ល្បែងចប់ +Name[ko]=SameGame +Name[lt]=Žaidimas baigtas +Name[lv]=Spēles beigas +Name[mk]=Играта заврши +Name[mt]=Il-Logħba Spiċċat +Name[nb]=Spillet er slutt +Name[nds]=Speel vörbi +Name[ne]=खेल समाप्त +Name[nl]=Spel is afgelopen +Name[nn]=Spelet er slutt +Name[nso]=Papadi e Fedile +Name[pa]=ਖੇਡ ਖਤਮ +Name[pl]=Koniec gry +Name[pt]=Fim do jogo +Name[pt_BR]=Fim do jogo +Name[ro]=Joc terminat +Name[ru]=Конец игры +Name[se]=Speallu nogai +Name[sk]=Koniec hry +Name[sl]=Konec igre +Name[sr]=Крај игре +Name[sr@Latn]=Kraj igre +Name[sv]=Spelet är slut +Name[ta]=ஆட்டம் முடிந்தது +Name[tg]=Бозӣ ба итмом расид +Name[th]=จบเกม +Name[tr]=Oyun Bitti +Name[uk]=Гру завершено +Name[uz]=Oʻyin tugadi +Name[uz@cyrillic]=Ўйин тугади +Name[ven]=Muthambo wo Fhela +Name[vi]=Game kết thúc +Name[wa]=Li djeu est houte +Name[xh]=Uphelile Umdlalo +Name[zh_CN]=游戏结束 +Name[zh_TW]=遊戲結束 +Name[zu]=Umdlalo uphelile +Comment=Game over +Comment[be]=Канец гульні +Comment[bg]=Край на играта +Comment[bn]=খেল খতম +Comment[br]=Echu an abadenn +Comment[bs]=Kraj igre +Comment[ca]=Fi de la partida +Comment[cs]=Hra skončena +Comment[cy]=Gêm drosodd +Comment[da]=Spil forbi +Comment[de]=Das Spiel ist vorbei +Comment[el]=Τέλος παιχνιδιού +Comment[eo]=Ludo finita +Comment[es]=Fin de la partida +Comment[et]=Mäng läbi +Comment[eu]=Jokoa amaitu da +Comment[fa]=بازی تمام شد +Comment[fi]=Peli loppui +Comment[fr]=Fin de la partie +Comment[ga]=Cluiche thart +Comment[he]=סיום משחק +Comment[hr]=Kraj igre +Comment[hu]=Vége a játéknak +Comment[is]=Leik lokið +Comment[it]=Gioco terminato +Comment[ja]=ゲームオーバー +Comment[km]=ល្បែងចប់ +Comment[lt]=Žaidimas baigtas +Comment[lv]=Spēle beigusies +Comment[mk]=Играта заврши +Comment[nb]=Spillet er slutt +Comment[nds]=Speel vörbi +Comment[ne]=खेल समाप्त +Comment[nl]=Het spel is afgelopen +Comment[nn]=Spelet er slutt +Comment[pa]=ਖੇਡ ਖਤਮ +Comment[pl]=Koniec gry +Comment[pt]=Fim do jogo +Comment[pt_BR]=Fim do Jogo +Comment[ru]=Конец игры +Comment[se]=Speallu nogai +Comment[sk]=Koniec hry +Comment[sl]=Konec igre +Comment[sr]=Крај игре +Comment[sr@Latn]=Kraj igre +Comment[sv]=Spelet slut +Comment[ta]=ஆட்டம் முடிந்தது +Comment[tr]=Oyun bitti +Comment[uk]=Кінець гри +Comment[wa]=Li djeu est houte +Comment[zh_CN]=游戏结束 +Comment[zh_TW]=遊戲結束 +default_presentation=0 + +[glued] +Name=Piece glued +Name[ar]=لقد ألصقت القطعة +Name[be]=Кавалачак зліпнуўся +Name[bg]=Залепени са парчета +Name[bn]=গুটি আটকে আছে +Name[bs]=Komad spojen +Name[ca]=Peça enganxada +Name[cs]=Blok spojen +Name[cy]=Darn wedi ei gludo +Name[da]=Brik klæbet fast +Name[de]=Zusammengefügte Klötzchen +Name[el]=Το κομμάτι κολλήθηκε +Name[eo]=Peco gluita +Name[es]=Ficha pegada +Name[et]=Kleepunud klots +Name[eu]=Pieza itsatsita +Name[fa]=قطعه چسبید +Name[fi]=Pala liimattu +Name[fr]=Morceau collé +Name[gl]=Peza pegada +Name[he]=חתיכה מודבקת +Name[hi]=टुकड़े चिपकाए +Name[hr]=Zalijepljeni dio +Name[hu]=Elem lekötve +Name[is]=Hlutur límdur +Name[it]=Pezzo incollato +Name[ja]=ピースをくっつけた +Name[km]=បំណែកបានបិទ +Name[lt]=Dalis įklijuota +Name[lv]=Pielīmēts gabals +Name[mk]=Залепено е парче +Name[nb]=Brikke festet +Name[nds]=Steen tosamenbackt +Name[ne]=टाँसिएको टुक्रा +Name[nl]=Samengevoegde stukken +Name[nn]=Brikke festa +Name[pl]=Sklejenie elementów +Name[pt]=Peça colada +Name[pt_BR]=Peça colada +Name[ru]=Слипание яиц +Name[se]=Bihttá lea liibmejuvvon +Name[sk]=Kus zlepený +Name[sl]=Kos prilepljen +Name[sr]=Залепљено парче +Name[sr@Latn]=Zalepljeno parče +Name[sv]=Pjäs fastsatt +Name[ta]= துண்டு கிலூயிட் +Name[tg]=Қисмҳои часбанда +Name[tr]=Yapıştırılan parçalar +Name[uk]=Фігура приклеєна +Name[zh_CN]=粘连的块数 +Name[zh_TW]=黏著的小碎片 +Comment=Piece glued +Comment[ar]=لقد ألصقت القطعة +Comment[be]=Кавалачак зліпнуўся +Comment[bg]=Залепени са парчета +Comment[bn]=গুটি আটকে আছে +Comment[bs]=Komad spojen +Comment[ca]=Peça enganxada +Comment[cs]=Blok spojen +Comment[cy]=Darn wedi ei gludo +Comment[da]=Brik klæbet fast +Comment[de]=Zusammengefügte Klötzchen +Comment[el]=Το κομμάτι κολλήθηκε +Comment[eo]=Peco gluita +Comment[es]=Ficha pegada +Comment[et]=Paikapandud klots +Comment[eu]=Pieza itsatsita +Comment[fa]=قطعه چسبید +Comment[fi]=Pala liimattu +Comment[fr]=Morceau collé +Comment[gl]=Peza pegada +Comment[he]=חתיכה מודבקת +Comment[hi]=टुकड़े चिपकाए +Comment[hr]=Zalijepljeni dio +Comment[hu]=Elem lekötve +Comment[is]=Hlutur límdur +Comment[it]=Pezzo incollato +Comment[ja]=ピースをくっつけた +Comment[km]=បំណែកបានបិទ +Comment[lt]=Dalis įklijuota +Comment[lv]=Gabals ir pielīmēts +Comment[mk]=Залепено е парче +Comment[nb]=Brikke festet +Comment[nds]=Steen tosamenbackt +Comment[ne]=टाँसिएको टुक्रा +Comment[nl]=Samengevoegde stukken +Comment[nn]=Brikke festa +Comment[pl]=Sklejenie elementu +Comment[pt]=Peça colada +Comment[pt_BR]=Peça colada +Comment[ru]=Слипание яиц +Comment[se]=Bihttá lea liibmejuvvon +Comment[sk]=Kus zlepený +Comment[sl]=Kos prilepljen +Comment[sr]=Залепљено парче +Comment[sr@Latn]=Zalepljeno parče +Comment[sv]=Pjäs fastsatt +Comment[ta]=துண்டு ஒட்டப்பட்டது +Comment[tg]=Қисмҳои часбанда +Comment[tr]=Parça yapıştırıldı +Comment[uk]=Фігура приклеєна +Comment[zh_CN]=粘连的块数 +default_presentation=0 diff --git a/ksirtet/ksirtet/field.cpp b/ksirtet/ksirtet/field.cpp new file mode 100644 index 00000000..e3384a9e --- /dev/null +++ b/ksirtet/ksirtet/field.cpp @@ -0,0 +1,61 @@ +#include "field.h" +#include "field.moc" + +#include <qwhatsthis.h> + +#include <klocale.h> +#include <kgamelcd.h> + +#include "board.h" +#include "prefs.h" +#include "piece.h" + +//----------------------------------------------------------------------------- +KSField::KSField(QWidget *parent) + : Field(parent) +{ + const Board *b = static_cast<Board *>(board); + QWhatsThis::add(b->giftPool(), i18n("Indicate the number of garbage lines you received from your opponent.")); +} + +void KSField::removedUpdated() +{ + KGameLCD *lcd = static_cast<KGameLCD *>(removedList->lcd(0)); + lcd->displayInt(board->nbRemoved()); + if ( board->nbRemoved() ) lcd->highlight(); + if ( Prefs::showDetailedRemoved() ) { + const KSBoard *ksb = static_cast<const KSBoard *>(board); + for (uint i=0; i<4; i++) { + if ( !(ksb->lastRemoved() & (2<<i)) ) continue; + lcd = static_cast<KGameLCD *>(removedList->lcd(i+1)); + lcd->displayInt(ksb->nbRemovedLines(i)); + if ( ksb->nbRemovedLines(i) ) lcd->highlight(); + } + } +} + +void KSField::settingsChanged() +{ + Field::settingsChanged(); + bool b = Prefs::oldRotationStyle(); + static_cast<KSPieceInfo &>(Piece::info()).setOldRotationStyle(b); + + removedList->clear(); + QWhatsThis::remove(removedList); + KGameLCD *lcd = new KGameLCD(5, removedList); + QString s = (Prefs::showDetailedRemoved() ? i18n("Total:") : QString::null); + removedList->append(s, lcd); + lcd->displayInt( board->nbRemoved() ); + lcd->show(); + + if ( Prefs::showDetailedRemoved() ) { + for (uint i=0; i<4; i++) { + KGameLCD *lcd = new KGameLCD(5, removedList); + QString s = i18n("1 Line:", "%n Lines:", i+1); + removedList->append(s, lcd); + uint nb = static_cast<const KSBoard *>(board)->nbRemovedLines(i); + lcd->displayInt(nb); + lcd->show(); + } + } +} diff --git a/ksirtet/ksirtet/field.h b/ksirtet/ksirtet/field.h new file mode 100644 index 00000000..4af498e9 --- /dev/null +++ b/ksirtet/ksirtet/field.h @@ -0,0 +1,19 @@ +#ifndef KS_FIELD_H +#define KS_FIELD_H + +#include "common/field.h" +#include "common/misc_ui.h" + + +class KSField : public Field +{ + Q_OBJECT + public: + KSField(QWidget *parent); + + private slots: + virtual void removedUpdated(); + virtual void settingsChanged(); +}; + +#endif diff --git a/ksirtet/ksirtet/hi128-app-ksirtet.png b/ksirtet/ksirtet/hi128-app-ksirtet.png Binary files differnew file mode 100644 index 00000000..4e96420b --- /dev/null +++ b/ksirtet/ksirtet/hi128-app-ksirtet.png diff --git a/ksirtet/ksirtet/hi16-app-ksirtet.png b/ksirtet/ksirtet/hi16-app-ksirtet.png Binary files differnew file mode 100644 index 00000000..ac3c6d33 --- /dev/null +++ b/ksirtet/ksirtet/hi16-app-ksirtet.png diff --git a/ksirtet/ksirtet/hi22-app-ksirtet.png b/ksirtet/ksirtet/hi22-app-ksirtet.png Binary files differnew file mode 100644 index 00000000..455fa6a8 --- /dev/null +++ b/ksirtet/ksirtet/hi22-app-ksirtet.png diff --git a/ksirtet/ksirtet/hi32-app-ksirtet.png b/ksirtet/ksirtet/hi32-app-ksirtet.png Binary files differnew file mode 100644 index 00000000..0ef40175 --- /dev/null +++ b/ksirtet/ksirtet/hi32-app-ksirtet.png diff --git a/ksirtet/ksirtet/hi48-app-ksirtet.png b/ksirtet/ksirtet/hi48-app-ksirtet.png Binary files differnew file mode 100644 index 00000000..481d8d61 --- /dev/null +++ b/ksirtet/ksirtet/hi48-app-ksirtet.png diff --git a/ksirtet/ksirtet/hi64-app-ksirtet.png b/ksirtet/ksirtet/hi64-app-ksirtet.png Binary files differnew file mode 100644 index 00000000..84d016fb --- /dev/null +++ b/ksirtet/ksirtet/hi64-app-ksirtet.png diff --git a/ksirtet/ksirtet/ksirtet.desktop b/ksirtet/ksirtet/ksirtet.desktop new file mode 100644 index 00000000..bfd9ef35 --- /dev/null +++ b/ksirtet/ksirtet/ksirtet.desktop @@ -0,0 +1,68 @@ +[Desktop Entry] +Name=KSirtet +Name[af]=Ksirtet +Name[be]=Сіртэтрыс +Name[bn]=কে-সরিটটে +Name[hi]=के-सिर्टेट +Name[ne]=केडीई सरटेट +Name[pl]=Sirtet (anagram) +Name[sv]=Ksirtet +Name[ta]=Kசர்டெட் +Name[tg]=KСиртетрис +Name[zh_TW]=KSirtet 俄羅斯 +Name[zu]=I-KSirtet +Icon=ksirtet +Exec=ksirtet -caption "%c" %i %m +Type=Application +DocPath=ksirtet/index.html +GenericName=Tetris Game +GenericName[be]=Тэтрыс +GenericName[bg]=Тетрис +GenericName[bn]=টেট্রিস খেলা +GenericName[bs]=Igra Tetrisa +GenericName[ca]=Joc Tetris +GenericName[cs]=Hra Tetris +GenericName[cy]=Gêm Tetris +GenericName[da]=Tetris spil +GenericName[de]=Tetris Spiel +GenericName[el]=Παιχνίδι Tetris +GenericName[eo]="Tetris"-ludo +GenericName[es]=Juego de Tetris +GenericName[et]=Tetris +GenericName[eu]=Tetris jokoa +GenericName[fa]=بازی Tetris +GenericName[fi]=Tetris +GenericName[fr]=Jeu de Tetris +GenericName[ga]=Cluiche Tetris +GenericName[he]=משחק טטריס +GenericName[hr]=Tetris +GenericName[hu]=Tetrisz +GenericName[is]=Tetrisleikur +GenericName[it]=Gioco del Tetris +GenericName[ja]=テトリス +GenericName[km]=ល្បែង Tetris +GenericName[lt]=Tetrio žaidimas +GenericName[lv]=Tetris +GenericName[mk]=Игра Тетрис +GenericName[nb]=Tetrisspill +GenericName[nds]=Tetris-Speel +GenericName[ne]=टेट्रिस खेल +GenericName[nl]=Tetris-spel +GenericName[nn]=Tetrisspel +GenericName[pl]=Tetris +GenericName[pt]=Jogo de Tetris +GenericName[pt_BR]=Jogo de Tetris +GenericName[ru]=Сиртетрис +GenericName[se]=Tetrisspeallu +GenericName[sk]=Hra Tetris +GenericName[sl]=Igra Tetrisa +GenericName[sr]=Игра Tetris-а +GenericName[sr@Latn]=Igra Tetris-a +GenericName[sv]=Tetrisspel +GenericName[ta]=டெட்ரிஸ் விளையாட்டு +GenericName[uk]=Тетріс +GenericName[zh_CN]=俄罗斯方块 +GenericName[zh_TW]=俄羅斯方塊遊戲 +X-KDE-StartupNotify=true +X-DCOP-ServiceType=Multi +Categories=Qt;KDE;Game;ArcadeGame; diff --git a/ksirtet/ksirtet/ksirtet.kcfg b/ksirtet/ksirtet/ksirtet.kcfg new file mode 100644 index 00000000..d4053758 --- /dev/null +++ b/ksirtet/ksirtet/ksirtet.kcfg @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <group name="Options"> + <entry name="OldRotationStyle" type="Bool" key="old rotation style"> + <label>Use old rotation style.</label> + <default>false</default> + </entry> + </group> + <group name="AI"> + <entry name="Coefficient_OccupiedLines" type="Double" key="occupied lines COEF"> + <label>Occupied lines</label> + <default>-2.0</default> + <min>-100.0</min> + <max>0.0</max> + </entry> + <entry name="Coefficient_Holes" type="Double" key="holes COEF"> + <label>Number of holes</label> + <default>-4.0</default> + <min>-100.0</min> + <max>0.0</max> + </entry> + <entry name="Coefficient_Spaces" type="Double" key="spaces COEF"> + <label>Number of spaces</label> + <default>-2.0</default> + <min>-100.0</min> + <max>0.0</max> + </entry> + <entry name="Coefficient_Peak2Peak" type="Double" key="peak-to-peak COEF"> + <label>Peak-to-peak distance</label> + <default>-2.0</default> + <min>-100.0</min> + <max>0.0</max> + </entry> + <entry name="Coefficient_MeanHeight" type="Double" key="mean height COEF"> + <label>Mean height</label> + <default>0.0</default> + <min>-100.0</min> + <max>0.0</max> + </entry> + <entry name="Coefficient_FullLines" type="Double" key="full lines COEF"> + <label>Number of full lines</label> + <default>50.0</default> + <min>-0.0</min> + <max>100.0</max> + </entry> + <entry name="Trigger_FullLines" type="Int" key="full lines TRIG"> + <default>1</default> + <min>1</min> + <max>4</max> + </entry> + </group> +</kcfg> diff --git a/ksirtet/ksirtet/ksirtetui.rc b/ksirtet/ksirtet/ksirtetui.rc new file mode 100644 index 00000000..83a6386d --- /dev/null +++ b/ksirtet/ksirtet/ksirtetui.rc @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE kpartgui> +<kpartgui name="ksirtet" version="9"> + +<MenuBar> + <Menu name="multiplayers"><text>&Mode</text> + <Action name="mp_single_human"/> + <Action name="mp_arcade"/> + <Separator/> + <Action name="mp_human_vs_human"/> + <Action name="mp_human_vs_computer"/> + <Separator/> + <Action name="mp_more"/> + </Menu> +</MenuBar> + +<Menu name="popup"> + <Action name="options_show_menubar"/> + <Separator/> + <Action name="game_new"/> + <Separator/> + <Action name="game_pause"/> + <Action name="game_highscores"/> + <Action name="game_print"/> + <Separator/> + <Action name="game_quit"/> +</Menu> + +</kpartgui> diff --git a/ksirtet/ksirtet/main.cpp b/ksirtet/ksirtet/main.cpp new file mode 100644 index 00000000..a186038e --- /dev/null +++ b/ksirtet/ksirtet/main.cpp @@ -0,0 +1,91 @@ +#include "main.h" +#include "main.moc" + +#include <klocale.h> +#include <kapplication.h> +#include <khighscore.h> + +#include "common/inter.h" +#include "common/highscores.h" +#include "prefs.h" +#include "piece.h" + + +//----------------------------------------------------------------------------- +const MPGameInfo MP_GAME_INFO = { + "006", // multiplayer id (increase when incompatible changes are made) + 4, // max nb local games + 500, // interval + true, // IA allowed + 0, 0 // no setting slots +}; + +const MainData MAIN_DATA = { + "ksirtet", + I18N_NOOP("KSirtet"), + I18N_NOOP("KSirtet is an adaptation of the well-known Tetris game"), + "http://ksirtet.sourceforge.net/", + I18N_NOOP("Removed Lines"), + "2.1.11b", + "2.1.11b (1 September 2005)" +}; + +const uint HISTOGRAM_SIZE = 8; +const uint HISTOGRAM[HISTOGRAM_SIZE] = { + 1, 5000, 10000, 20000, 50000, 100000, 200000, 300000 +}; + +const BaseBoardInfo BASE_BOARD_INFO = { + KSBoard::Width, 22, // width - height + true, // with pieces + + 150, // before remove time + 10, // after remove time + 3, // nb toggles + 5, // nb partial fall stages + + KSBoard::Nb_Stages, // nb arcade stages + + HISTOGRAM, HISTOGRAM_SIZE, false, // score is not bound +}; + +const CommonBoardInfo COMMON_BOARD_INFO = { + 1000, // base time + 20, // drop down time + 10, // before glue time + 10, // after glue time + 10, // after gift time + 3, // nb bump stages + 10, // nb removed to level + 3, 3, 800, 2000 // nb leds, nb max to send, shower timeout, pool timeout +}; + +KSFactory::KSFactory() + : CommonFactory(MAIN_DATA, BASE_BOARD_INFO, COMMON_BOARD_INFO) +{} + +BaseInterface *KSFactory::createInterface(QWidget *parent) +{ + return new Interface(MP_GAME_INFO, parent); +} + +//----------------------------------------------------------------------------- +int main(int argc, char **argv) +{ + KHighscore::init(MAIN_DATA.appName); + KSFactory ksf; + ksf.init(argc, argv); + + KSPieceInfo pieceInfo; + CommonHighscores highscores; + + (void) Prefs::self(); // Create preferences + + if ( kapp->isRestored() ) RESTORE(KSMainWindow) + else { + KSMainWindow *mw = new KSMainWindow; + kapp->setMainWidget(mw); + mw->show(); + } + return kapp->exec(); +} diff --git a/ksirtet/ksirtet/main.h b/ksirtet/ksirtet/main.h new file mode 100644 index 00000000..67fe3619 --- /dev/null +++ b/ksirtet/ksirtet/main.h @@ -0,0 +1,36 @@ +#ifndef KS_MAIN_H +#define KS_MAIN_H + +#include "common/main.h" +#include "common/factory.h" +#include "ai.h" +#include "settings.h" +#include "board.h" +#include "field.h" + + +//----------------------------------------------------------------------------- +class KSFactory : public CommonFactory +{ + public: + KSFactory(); + + protected: + virtual BaseBoard *createBoard(bool graphic, QWidget *parent) + { return new KSBoard(graphic, parent); } + virtual BaseField *createField(QWidget *parent) + { return new KSField(parent); } + virtual BaseInterface *createInterface(QWidget *parent); + virtual AI *createAI() { return new KSAI; } + virtual QWidget *createGameConfig() { return new KSGameConfig; } +}; + +//----------------------------------------------------------------------------- +class KSMainWindow : public MainWindow +{ + Q_OBJECT + public: + KSMainWindow() { init(); } +}; + +#endif diff --git a/ksirtet/ksirtet/piece.cpp b/ksirtet/ksirtet/piece.cpp new file mode 100644 index 00000000..67ba2635 --- /dev/null +++ b/ksirtet/ksirtet/piece.cpp @@ -0,0 +1,82 @@ +#include "piece.h" + +#include <qpainter.h> +#include <klocale.h> + + +const KSPieceInfo::Form KSPieceInfo::FORMS[NB_FORMS] = { + { {{-1, -1, 0, 0}, {-1, 0, 0, 1}, {-1, -1, 0, 0}, {-1, 0, 0, 1}}, + {{ 1, 0, 0, -1}, {-1, -1, 0, 0}, { 1, 0, 0, -1}, {-1, -1, 0, 0}}, + {{ 0, 0, -1, -1}, { 1, 0, 0, -1}, { 0, 0, 1, 1}, {-1, 0, 0, 1}}, + {{-1, 0, 0, 1}, { 0, 0, -1, -1}, { 1, 0, 0, -1}, { 0, 0, 1, 1}}, + 2 }, // broken line Z + { {{-1, -1, 0, 0}, {-1, 0, 0, 1}, {-1, -1, 0, 0}, {-1, 0, 0, 1}}, + {{-1, 0, 0, 1}, { 0, 0, -1, -1}, {-1, 0, 0, 1}, { 0, 0, -1, -1}}, + {{ 0, 0, 1, 1}, { 1, 0, 0, -1}, { 0, 0, -1, -1}, {-1, 0, 0, 1}}, + {{-1, 0, 0, 1}, { 0, 0, 1, 1}, { 1, 0, 0, -1}, { 0, 0, -1, -1}}, + 2 }, // broken line S + { {{ 0, 0, 0, 0}, {-1, 0, 1, 2}, { 0, 0, 0, 0}, {-1, 0, 1, 2}}, + {{-1, 0, 1, 2}, { 0, 0, 0, 0}, {-1, 0, 1, 2}, { 0, 0, 0, 0}}, + {{ 0, 0, 0, 0}, { 1, 0, -1, -2}, { 0, 0, 0, 0}, {-1, 0, 1, 2}}, + {{-1, 0, 1, 2}, { 0, 0, 0, 0}, { 1, 0, -1, -2}, { 0, 0, 0, 0}}, + 2 }, // line + { {{ 0, 0, 1, 0}, {-1, 1, 0, 0}, { 0, 0, -1, 0}, { 1, -1, 0, 0}}, + {{ 1, -1, 0, 0}, { 0, 0, 1, 0}, {-1, 1, 0, 0}, { 0, 0, -1, 0}}, + {{-1, 0, 1, 0}, { 0, 0, 0, 1}, { 1, 0, -1, 0}, { 0, 0, 0, -1}}, + {{ 0, 0, 0, -1}, {-1, 0, 1, 0}, { 0, 0, 0, 1}, { 1, 0, -1, 0}}, + 4 }, // T + { {{-1, 0, -1, 0}, {-1, 0, -1, 0}, {-1, 0, -1, 0}, {-1, 0, -1, 0}}, + {{ 0, 0, -1, -1}, { 0, 0, -1, -1}, { 0, 0, -1, -1}, { 0, 0, -1, -1}}, + {{-1, 0, -1, 0}, { 0, 0, -1, -1}, { 1, 0, 1, 0}, { 0, 0, 1, 1}}, + {{ 0, 0, 1, 1}, {-1, 0, -1, 0}, { 0, 0, -1, -1}, { 1, 0, 1, 0}}, + 1 }, // square + { {{ 1, 1, 1, 0}, {-1, 0, 1, 1}, {-1, -1, -1, 0}, { 1, 0, -1, -1}}, + {{ 1, 0, -1, -1}, { 1, 1, 1, 0}, {-1, 0, 1, 1}, {-1, -1, -1, 0}}, + {{-1, 0, 0, 0}, { 1, 1, 0, -1}, { 1, 0, 0, 0}, {-1, -1, 0, 1}}, + {{-1, -1, 0, 1}, {-1, 0, 0, 0}, { 1, 1, 0, -1}, { 1, 0, 0, 0}}, + 4 }, // backward L + { {{-1, -1, -1, 0}, {-1, 0, 1, 1}, { 1, 1, 1, 0}, { 1, 0, -1, -1}}, + {{ 1, 0, -1, -1}, {-1, -1, -1, 0}, {-1, 0, 1, 1}, { 1, 1, 1, 0}}, + {{ 1, 0, 0, 0}, { 1, 1, 0, -1}, {-1, 0, 0, 0}, {-1, -1, 0, 1}}, + {{-1, -1, 0, 1}, { 1, 0, 0, 0}, { 1, 1, 0, -1}, {-1, 0, 0, 0}}, + 4 } // L +}; + +const char *KSPieceInfo::COLOR_LABELS[NB_FORMS+1] = { + I18N_NOOP("Z piece color:"), I18N_NOOP("S piece color:"), + I18N_NOOP("I piece color:"), I18N_NOOP("T piece color:"), + I18N_NOOP("Square color:"), I18N_NOOP("Mirrored L piece color:"), + I18N_NOOP("L piece color:"), I18N_NOOP("Garbage block color:") +}; + +const char *KSPieceInfo::DEFAULT_COLORS[NB_FORMS+1] = { + "#C86464", "#64C864", "#6464C8", "#C8C864", "#C864C8","#64C8C8", "#DAAA00", + "#C8C8C8" +}; + +QColor KSPieceInfo::defaultColor(uint i) const +{ + if ( i>=nbColors() ) return QColor(); + return QColor(DEFAULT_COLORS[i]); +} + +void KSPieceInfo::draw(QPixmap *pixmap, uint blockType, uint, + bool lighted) const +{ + QColor col = color(blockType); + if (lighted) col = col.light(); + pixmap->fill(col); + + QPainter p(pixmap); + QRect r = pixmap->rect(); + + p.setPen( col.light() ); + p.moveTo(r.bottomLeft()); + p.lineTo(r.topLeft()); + p.lineTo(r.topRight()); + + p.setPen( col.dark() ); + p.moveTo(r.topRight() + QPoint(0,1)); + p.lineTo(r.bottomRight()); + p.lineTo(r.bottomLeft() + QPoint(1,0)); +} diff --git a/ksirtet/ksirtet/piece.h b/ksirtet/ksirtet/piece.h new file mode 100644 index 00000000..25d866c4 --- /dev/null +++ b/ksirtet/ksirtet/piece.h @@ -0,0 +1,63 @@ +#ifndef KS_PIECE_H +#define KS_PIECE_H + +#include <klocale.h> +#include "base/piece.h" + + +class KSPieceInfo : public GPieceInfo +{ + public: + KSPieceInfo() : _oldRotationStyle(false) {} + + void setOldRotationStyle(bool oldStyle) { _oldRotationStyle = oldStyle; } + + virtual uint nbBlocks() const { return NB_BLOCKS; } + virtual uint nbForms() const { return NB_FORMS; } + virtual uint nbTypes() const { return NB_FORMS; } + + virtual const int *i(uint form, uint rot) const { + return (_oldRotationStyle ? FORMS[form].oi[rot] : FORMS[form].i[rot]); + } + virtual const int *j(uint form, uint rot) const { + return (_oldRotationStyle ? FORMS[form].oj[rot] : FORMS[form].j[rot]); + } + virtual uint value(uint type, uint) const { return type; } + virtual uint form(uint type) const { return type; } + virtual uint nbConfigurations(uint type) const { return FORMS[type].nbConfigs; } + + virtual uint nbNormalBlockTypes() const { return NB_FORMS; } + virtual uint nbGarbageBlockTypes() const { return 1; } + virtual uint nbBlockModes() const { return 1; } + + virtual uint nbColors() const { return NB_FORMS + 1; } + virtual QString colorLabel(uint i) const { return i18n(COLOR_LABELS[i]); } + virtual QColor defaultColor(uint i) const; + + private: + virtual void draw(QPixmap *, uint blockType, uint blockMode, + bool lighted) const; + + private: + bool _oldRotationStyle; + + enum { NB_BLOCKS = 4, + NB_FORMS = 7 }; + + struct Form { + int i[4][NB_BLOCKS]; // new rotation style + int j[4][NB_BLOCKS]; + int oi[4][NB_BLOCKS]; // old rotation style + int oj[4][NB_BLOCKS]; + uint nbConfigs; // number of unique configs + }; + static const Form FORMS[NB_FORMS]; + + static const char *COLOR_LABELS[NB_FORMS+1]; + static const char *DEFAULT_COLORS[NB_FORMS+1]; +}; + +#endif + + + diff --git a/ksirtet/ksirtet/prefs.kcfgc b/ksirtet/ksirtet/prefs.kcfgc new file mode 100644 index 00000000..1201abb3 --- /dev/null +++ b/ksirtet/ksirtet/prefs.kcfgc @@ -0,0 +1,9 @@ +# Code generation options for kconfig_compiler +File=ksirtet.kcfg +IncludeFiles=common/commonprefs.h +Inherits=CommonPrefs +ClassName=Prefs +Singleton=true +#Mutators=true +#CustomAdditions=true +#Mutators=true diff --git a/ksirtet/ksirtet/settings.cpp b/ksirtet/ksirtet/settings.cpp new file mode 100644 index 00000000..96669e78 --- /dev/null +++ b/ksirtet/ksirtet/settings.cpp @@ -0,0 +1,17 @@ +#include "settings.h" +#include "settings.moc" + +#include <qlayout.h> +#include <qcheckbox.h> + +#include <klocale.h> + + +KSGameConfig::KSGameConfig() +{ + int row = _grid->numRows(); + int col = _grid->numCols(); + + QCheckBox *cb = new QCheckBox(i18n("Old rotation style"), this, "kcfg_OldRotationStyle"); + _grid->addMultiCellWidget(cb, row, row, 0, col-1); +} diff --git a/ksirtet/ksirtet/settings.h b/ksirtet/ksirtet/settings.h new file mode 100644 index 00000000..7e945db6 --- /dev/null +++ b/ksirtet/ksirtet/settings.h @@ -0,0 +1,14 @@ +#ifndef KS_SETTINGS_H +#define KS_SETTINGS_H + +#include "common/settings.h" + + +class KSGameConfig : public GameConfig +{ + Q_OBJECT + public: + KSGameConfig(); +}; + +#endif |