Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package It.uniroma3.diadia.comandi;
- import It.uniroma3.diadia.Partita;
- import It.uniroma3.diadia.attrezzi.Attrezzo;
- public class ComandoRegalo implements Comando {
- private String nomeAttrezzo;
- private String messaggio;
- @Override
- public String esegui(Partita partita) {
- if(this.getParametro() == null){
- return "che cosa vuoi regalare?";
- }
- if(!partita.getGiocatore().getBorsa().hasAttrezzo(getParametro())){
- return "Non hai un attrezzo simile!";
- }
- if(partita.getStanzaCorrente().getPersonaggio() != null){
- Attrezzo dono = partita.getGiocatore().getBorsa().getAttrezzo(nomeAttrezzo);
- this.messaggio = partita.getStanzaCorrente().getPersonaggio().riceviRegalo(dono, partita);
- return this.messaggio;
- }
- else return "Non c'e' nessuno in questa stanza!";
- }
- @Override
- public void setParametro(String parametro) {
- this.nomeAttrezzo = parametro;
- }
- @Override
- public String getNome() {
- return "regala";
- }
- @Override
- public String getParametro() {
- return this.nomeAttrezzo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement