Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Quentin DRUAULT-AUBIN
lo23-project
Commits
e4daa948
Commit
e4daa948
authored
Jan 02, 2018
by
dkonam
Browse files
Data | ia chat
parent
0f26b285
Changes
2
Hide whitespace changes
Inline
Side-by-side
Battleship/src/main/java/com/utclo23/data/module/GameMediator.java
View file @
e4daa948
...
@@ -20,6 +20,7 @@ import java.util.ArrayList;
...
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
...
@@ -291,7 +292,11 @@ public class GameMediator {
...
@@ -291,7 +292,11 @@ public class GameMediator {
if
(
this
.
currentGame
.
getComputerPlayer
().
getFocus
()
!=
null
)
{
if
(
this
.
currentGame
.
getComputerPlayer
().
getFocus
()
!=
null
)
{
}
}
}
}
Random
r
=
new
Random
();
if
(
r
.
nextInt
(
5
)==
1
){
this
.
sendMessageIA
();
}
}
}
}
else
{
}
else
{
...
@@ -391,7 +396,7 @@ public class GameMediator {
...
@@ -391,7 +396,7 @@ public class GameMediator {
LightPublicUser
sender
=
this
.
dataFacade
.
getMyPublicUserProfile
().
getLightPublicUser
();
LightPublicUser
sender
=
this
.
dataFacade
.
getMyPublicUserProfile
().
getLightPublicUser
();
//check if sender is spectator and if chat is allowed for spectators
//check if sender is spectator and if chat is allowed for spectators
if
(
this
.
currentGame
.
getSpectators
().
contains
(
sender
))
{
if
(
this
.
currentGame
.
getSpectators
().
contains
(
sender
)
||
this
.
currentGame
.
getRecipients
(
""
).
contains
(
sender
)
)
{
if
(!
this
.
currentGame
.
getStatGame
().
isSpectatorChat
())
{
if
(!
this
.
currentGame
.
getStatGame
().
isSpectatorChat
())
{
return
;
return
;
}
}
...
@@ -404,6 +409,40 @@ public class GameMediator {
...
@@ -404,6 +409,40 @@ public class GameMediator {
}
}
}
}
public
void
sendMessageIA
()
{
System
.
out
.
println
(
"IA send message"
);
List
<
String
>
punchlines
=
new
ArrayList
<
String
>();
punchlines
.
add
(
"Tu vas bientôt perdre !"
);
punchlines
.
add
(
"Tu as autant de chance de gagner que d'avoir A en LO23"
);
punchlines
.
add
(
"zZz zZz Je m'ennuie avec toi. Tu joues mal."
);
punchlines
.
add
(
"Tu crois pouvoir battre une IA ?"
);
punchlines
.
add
(
"LOL"
);
Random
r
=
new
Random
();
int
i
=
r
.
nextInt
(
punchlines
.
size
());
String
text
=
punchlines
.
get
(
i
);
//get information of sender
LightPublicUser
sender
=
this
.
currentGame
.
getComputerPlayer
().
getLightPublicUser
();
//check if sender is spectator and if chat is allowed for spectators
if
(!
this
.
currentGame
.
getStatGame
().
isSpectatorChat
())
{
return
;
}
Message
msg
=
new
Message
(
sender
,
text
,
this
.
currentGame
.
getRecipients
(
this
.
dataFacade
.
getMyPublicUserProfile
().
getPlayerName
()));
ComFacade
comFacade
=
this
.
dataFacade
.
getComfacade
();
if
(
comFacade
!=
null
)
{
comFacade
.
notifyNewMessage
(
msg
);
}
this
.
forwardMessage
(
msg
);
System
.
out
.
println
(
"IA send message end"
);
}
/**
/**
* Forward a message
* Forward a message
*
*
...
...
Battleship/src/main/java/com/utclo23/ihmmain/controller/CreateGameController.java
View file @
e4daa948
...
@@ -72,7 +72,10 @@ public class CreateGameController extends AbstractController{
...
@@ -72,7 +72,10 @@ public class CreateGameController extends AbstractController{
// Default values
// Default values
radioButtonClassical
.
setSelected
(
true
);
radioButtonClassical
.
setSelected
(
true
);
radioButtonComputer
.
setSelected
(
true
);
radioButtonComputer
.
setSelected
(
true
);
radioButtonChat
.
setSelected
(
true
);
radioButtonAudience
.
setSelected
(
true
);
}
}
public
void
start
(){
public
void
start
(){
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment