Skip to contentMethod: applyTo(GDState, GDPlayer)
      1: /*
2:  * Copyright © 2021-2023 Fachhochschule für die Wirtschaft (FHDW) Hannover
3:  *
4:  * This file is part of ipspiel24-GD.
5:  *
6:  * ipspiel24-GD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
7:  * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
8:  * version.
9:  *
10:  * ipspiel24-GD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
11:  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12:  *
13:  * You should have received a copy of the GNU General Public License along with ipspiel24-GD. If not, see
14:  * <http://www.gnu.org/licenses/>.
15:  */
16: package de.fhdw.gaming.GefangenenDilemma.moves.impl;
17: 
18: import de.fhdw.gaming.GefangenenDilemma.domain.GDPlayer;
19: import de.fhdw.gaming.GefangenenDilemma.domain.GDState;
20: import de.fhdw.gaming.GefangenenDilemma.domain.impl.GDGameBuilderFactoryImpl;
21: import de.fhdw.gaming.core.domain.GameException;
22: 
23: /**
24:  * Says "no".
25:  */
26: public class GDRandomMove extends AbstractGDMove {
27: 
28:     @Override
29:     public void applyTo(final GDState state, final GDPlayer player) throws GameException {
30:•        if (player.getRandom().nextBoolean()) {
31:             player.setAnswer(GDGameBuilderFactoryImpl.MOVES.SNITCH);
32: 
33:         } else {
34:             player.setAnswer(GDGameBuilderFactoryImpl.MOVES.REMAINSILENT);
35:         }
36:     }
37: 
38:     @Override
39:     public String toString() {
40:         return "Snitching";
41:     }
42: }