Randomise order of play.
authornemo
Sun, 24 Jan 2010 07:26:03 +0000
changeset 2703 fbde0d971ba6
parent 2702 48fc46a922fd
child 2704 51cda17b7c3b
Randomise order of play.
QTfrontend/ammoSchemeModel.cpp
QTfrontend/gamecfgwidget.cpp
QTfrontend/hedgewars.qrc
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/res/btnRandomOrder.png
hedgewars/uConsts.pas
hedgewars/uTeams.pas
--- a/QTfrontend/ammoSchemeModel.cpp	Sat Jan 23 21:57:24 2010 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp	Sun Jan 24 07:26:03 2010 +0000
@@ -35,13 +35,14 @@
 		<< QVariant(false)         // vampiric       9
 		<< QVariant(false)         // karma          10
 		<< QVariant(false)         // artillery      11
-		<< QVariant(100)           // damage modfier 12
-		<< QVariant(45)            // turn time      13
-		<< QVariant(100)           // init health    14
-		<< QVariant(15)            // sudden death   15
-		<< QVariant(5)             // case prob      16
-		<< QVariant(3)             //  mines time    17
-		<< QVariant(4)             //  landadds      18
+		<< QVariant(true)          // random order   12
+		<< QVariant(100)           // damage modfier 13
+		<< QVariant(45)            // turn time      14
+		<< QVariant(100)           // init health    15
+		<< QVariant(15)            // sudden death   16
+		<< QVariant(5)             // case prob      17
+		<< QVariant(3)             //  mines time    18
+		<< QVariant(4)             //  landadds      19
 		;
 
 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
@@ -70,13 +71,14 @@
 		<< "vampiric"         //  9
 		<< "karma"            // 10
 		<< "artillery"        // 11
-		<< "damagefactor"     // 12
-		<< "turntime"         // 13
-		<< "health"           // 14
-		<< "suddendeath"      // 15
-		<< "caseprobability"  // 16
-		<< "minestime"        // 17
-		<< "landadds"         // 18
+		<< "randomorder"      // 12
+		<< "damagefactor"     // 13
+		<< "turntime"         // 14
+		<< "health"           // 15
+		<< "suddendeath"      // 16
+		<< "caseprobability"  // 17
+		<< "minestime"        // 18
+		<< "landadds"         // 19
 		;
 
 	QList<QVariant> proMode;
@@ -93,13 +95,14 @@
 		<< QVariant(false)         // vampiric       9
 		<< QVariant(false)         // karma          10
 		<< QVariant(false)         // artillery      11
-		<< QVariant(100)           // damage modfier 12
-		<< QVariant(15)            // turn time      13
-		<< QVariant(100)           // init health    14
-		<< QVariant(15)            // sudden death   15
-		<< QVariant(0)             // case prob      16
-		<< QVariant(3)             //  mines time    17
-		<< QVariant(4)             //  landadds      18
+		<< QVariant(true)          // random order   12
+		<< QVariant(100)           // damage modfier 13
+		<< QVariant(15)            // turn time      14
+		<< QVariant(100)           // init health    15
+		<< QVariant(15)            // sudden death   16
+		<< QVariant(0)             // case prob      17
+		<< QVariant(3)             //  mines time    18
+		<< QVariant(4)             //  landadds      19
 		;
 
 	QList<QVariant> shoppa;
@@ -116,13 +119,14 @@
 		<< QVariant(false)         // vampiric       9
 		<< QVariant(false)         // karma          10
 		<< QVariant(false)         // artillery      11
-		<< QVariant(100)           // damage modfier 12
-		<< QVariant(30)            // turn time      13
-		<< QVariant(100)           // init health    14
-		<< QVariant(50)            // sudden death   15
-		<< QVariant(1)             // case prob      16
-		<< QVariant(3)             //  mines time    17
-		<< QVariant(4)             //  landadds      18
+		<< QVariant(true)          // random order   12
+		<< QVariant(100)           // damage modfier 13
+		<< QVariant(30)            // turn time      14
+		<< QVariant(100)           // init health    15
+		<< QVariant(50)            // sudden death   16
+		<< QVariant(1)             // case prob      17
+		<< QVariant(3)             //  mines time    18
+		<< QVariant(4)             //  landadds      19
 		;
 
 	QList<QVariant> basketball;
@@ -139,13 +143,14 @@
 		<< QVariant(false)         // vampiric       9
 		<< QVariant(false)         // karma          10
 		<< QVariant(false)         // artillery      11
-		<< QVariant(100)           // damage modfier 12
-		<< QVariant(30)            // turn time      13
-		<< QVariant(100)           // init health    14
-		<< QVariant(15)            // sudden death   15
-		<< QVariant(0)             // case prob      16
-		<< QVariant(3)             //  mines time    17
-		<< QVariant(4)             //  landadds      18
+		<< QVariant(true)          // random order   12
+		<< QVariant(100)           // damage modfier 13
+		<< QVariant(30)            // turn time      14
+		<< QVariant(100)           // init health    15
+		<< QVariant(15)            // sudden death   16
+		<< QVariant(0)             // case prob      17
+		<< QVariant(3)             //  mines time    18
+		<< QVariant(4)             //  landadds      19
 		;
 
 	QList<QVariant> minefield;
@@ -162,13 +167,14 @@
 		<< QVariant(false)         // vampiric       9
 		<< QVariant(false)         // karma          10
 		<< QVariant(false)         // artillery      11
-		<< QVariant(150)           // damage modfier 12
-		<< QVariant(30)            // turn time      13
-		<< QVariant(50)            // init health    14
-		<< QVariant(15)            // sudden death   15
-		<< QVariant(0)             // case prob      16
-		<< QVariant(0)             //  mines time    17
-		<< QVariant(50)            //  landadds      18
+		<< QVariant(true)          // random order   12
+		<< QVariant(150)           // damage modfier 13
+		<< QVariant(30)            // turn time      14
+		<< QVariant(50)            // init health    15
+		<< QVariant(15)            // sudden death   16
+		<< QVariant(0)             // case prob      17
+		<< QVariant(0)             //  mines time    18
+		<< QVariant(50)            //  landadds      19
 		;
 
 	schemes.append(defaultScheme);
--- a/QTfrontend/gamecfgwidget.cpp	Sat Jan 23 21:57:24 2010 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Sun Jan 24 07:26:03 2010 +0000
@@ -113,13 +113,15 @@
 		result |= 0x400;
 	if (schemeData(11).toBool())
 		result |= 0x800;
+	if (schemeData(12).toBool())
+		result |= 0x2000;
 
 	return result;
 }
 
 quint32 GameCFGWidget::getInitHealth() const
 {
-	return schemeData(14).toInt();
+	return schemeData(15).toInt();
 }
 
 QStringList GameCFGWidget::getFullConfig() const
@@ -127,12 +129,12 @@
 	QStringList sl;
 	sl.append("eseed " + pMapContainer->getCurrentSeed());
 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
-	sl.append(QString("e$damagepct %1").arg(schemeData(12).toInt()));
-	sl.append(QString("e$turntime %1").arg(schemeData(13).toInt() * 1000));
-	sl.append(QString("e$minestime %1").arg(schemeData(17).toInt() * 1000));
-	sl.append(QString("e$landadds %1").arg(schemeData(18).toInt()));
-	sl.append(QString("e$sd_turns %1").arg(schemeData(15).toInt()));
-	sl.append(QString("e$casefreq %1").arg(schemeData(16).toInt()));
+	sl.append(QString("e$damagepct %1").arg(schemeData(13).toInt()));
+	sl.append(QString("e$turntime %1").arg(schemeData(14).toInt() * 1000));
+	sl.append(QString("e$minestime %1").arg(schemeData(18).toInt() * 1000));
+	sl.append(QString("e$landadds %1").arg(schemeData(19).toInt()));
+	sl.append(QString("e$sd_turns %1").arg(schemeData(16).toInt()));
+	sl.append(QString("e$casefreq %1").arg(schemeData(17).toInt()));
 	sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
 
 	QString currentMap = pMapContainer->getCurrentMap();
--- a/QTfrontend/hedgewars.qrc	Sat Jan 23 21:57:24 2010 +0000
+++ b/QTfrontend/hedgewars.qrc	Sun Jan 24 07:26:03 2010 +0000
@@ -56,6 +56,7 @@
     <file>res/btnVampiric.png</file>
     <file>res/btnKarma.png</file>
     <file>res/btnArtillery.png</file>
+    <file>res/btnRandomOrder.png</file>
     <file>res/iconBox.png</file>
     <file>res/iconHealth.png</file>
     <file>res/iconSuddenDeath.png</file>
--- a/QTfrontend/pages.cpp	Sat Jan 23 21:57:24 2010 +0000
+++ b/QTfrontend/pages.cpp	Sun Jan 24 07:26:03 2010 +0000
@@ -1049,6 +1049,11 @@
     TBW_artillery->setToolTip(tr("Your hogs are unable to move, put your artillery skills to the test"));
 	glGMLayout->addWidget(TBW_artillery,2,2,1,1);
 
+	TBW_randomorder = new ToggleButtonWidget(gbGameModes, ":/res/btnRandomOrder.png");
+	TBW_randomorder->setText(ToggleButtonWidget::tr("Random Order"));
+    TBW_randomorder->setToolTip(tr("Order of play is random instead of in room order."));
+	glGMLayout->addWidget(TBW_randomorder,2,3,1,1);
+
 	// Right
 	QLabel * l;
 
@@ -1196,13 +1201,14 @@
 	mapper->addMapping(TBW_vampiric->button(), 9);
 	mapper->addMapping(TBW_karma->button(), 10);
 	mapper->addMapping(TBW_artillery->button(), 11);
-	mapper->addMapping(SB_DamageModifier, 12);
-	mapper->addMapping(SB_TurnTime, 13);
-	mapper->addMapping(SB_InitHealth, 14);
-	mapper->addMapping(SB_SuddenDeath, 15);
-	mapper->addMapping(SB_CaseProb, 16);
-	mapper->addMapping(SB_MinesTime, 17);
-	mapper->addMapping(SB_Mines, 18);
+	mapper->addMapping(TBW_randomorder->button(), 12);
+	mapper->addMapping(SB_DamageModifier, 13);
+	mapper->addMapping(SB_TurnTime, 14);
+	mapper->addMapping(SB_InitHealth, 15);
+	mapper->addMapping(SB_SuddenDeath, 16);
+	mapper->addMapping(SB_CaseProb, 17);
+	mapper->addMapping(SB_MinesTime, 18);
+	mapper->addMapping(SB_Mines, 19);
 
 	mapper->toFirst();
 }
--- a/QTfrontend/pages.h	Sat Jan 23 21:57:24 2010 +0000
+++ b/QTfrontend/pages.h	Sun Jan 24 07:26:03 2010 +0000
@@ -433,6 +433,7 @@
 	ToggleButtonWidget * TBW_vampiric;
 	ToggleButtonWidget * TBW_karma;
 	ToggleButtonWidget * TBW_artillery;
+	ToggleButtonWidget * TBW_randomorder;
 
 	QSpinBox * SB_DamageModifier;
 	QSpinBox * SB_TurnTime;
Binary file QTfrontend/res/btnRandomOrder.png has changed
--- a/hedgewars/uConsts.pas	Sat Jan 23 21:57:24 2010 +0000
+++ b/hedgewars/uConsts.pas	Sun Jan 24 07:26:03 2010 +0000
@@ -293,6 +293,7 @@
 	gfKarma        = $00000400;
 	gfArtillery    = $00000800;
 	gfOneClanMode  = $00001000;
+	gfRandomOrder  = $00002000;
 
 	gstDrowning       = $00000001;
 	gstHHDriven       = $00000002;
--- a/hedgewars/uTeams.pas	Sat Jan 23 21:57:24 2010 +0000
+++ b/hedgewars/uTeams.pas	Sun Jan 24 07:26:03 2010 +0000
@@ -309,7 +309,18 @@
 procedure InitTeams;
 var i, t: LongInt;
     th: LongInt;
+    cp: PClan;
 begin
+if (GameFlags and gfRandomOrder) <> 0 then  // shuffle them up a bit
+   for i:= 0 to ClansCount * 8 do
+      begin
+      t:= GetRandom(Pred(ClansCount))+1;
+      cp:= ClansArray[0];
+      ClansArray[0]:= ClansArray[t];
+      ClansArray[t]:= cp;
+      ClansArray[t]^.ClanIndex:= t;
+      ClansArray[0]^.ClanIndex:= 0;
+      end;
 for t:= 0 to Pred(TeamsCount) do
    with TeamsArray[t]^ do
       begin