Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pingouins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felton Samuel
pingouins
Commits
892f690f
Commit
892f690f
authored
8 years ago
by
Romain Lebouc
Browse files
Options
Downloads
Patches
Plain Diff
GUI: random generation of start now has a mawimum amount for every fish tile type
parent
53f834ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gui/src/controller/Controller.java
+12
-1
12 additions, 1 deletion
gui/src/controller/Controller.java
with
12 additions
and
1 deletion
gui/src/controller/Controller.java
+
12
−
1
View file @
892f690f
...
...
@@ -23,6 +23,7 @@ import java.io.IOException;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.ResourceBundle
;
...
...
@@ -32,6 +33,7 @@ public class Controller implements Initializable
private
static
final
String
iaProgramPath
=
"../bin/theturk"
;
private
static
final
String
introMusicFile
=
"./resource/pingu_theme.wav"
;
private
static
final
String
clickSoundFile
=
"./resource/clic.wav"
;
private
static
final
int
max1Fish
=
30
,
max2Fish
=
20
,
max3Fish
=
10
;
private
GameState
gameState
;
private
Process
gameProcess
;
...
...
@@ -121,12 +123,21 @@ public class Controller implements Initializable
gameState
.
setScore
(
Player
.
Red
,
0
);
gameState
.
setScore
(
Player
.
Blue
,
0
);
//Generating random fish values
int
[]
fishCount
=
{
0
,
0
,
0
};
for
(
int
i
=
0
;
i
<
60
;
i
++)
{
int
nbFish
=
new
Random
().
nextInt
(
3
)
+
1
;
List
<
Integer
>
possibleFish
=
new
ArrayList
<>();
if
(
fishCount
[
0
]
<
max1Fish
)
possibleFish
.
add
(
1
);
if
(
fishCount
[
1
]
<
max2Fish
)
possibleFish
.
add
(
2
);
if
(
fishCount
[
2
]
<
max3Fish
)
possibleFish
.
add
(
3
);
int
nbFish
=
possibleFish
.
get
(
new
Random
().
nextInt
(
possibleFish
.
size
()));
gameState
.
setFish
(
i
,
nbFish
);
board
[
i
].
setNbFish
(
nbFish
);
boardView
[
i
].
update
();
fishCount
[
nbFish
-
1
]++;
}
//Adding listener to add penguins
penguinGenCounter
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment