-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJugadorVirtual.java
65 lines (50 loc) · 1.63 KB
/
JugadorVirtual.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package domino;
import java.util.ArrayList;
import javax.sound.sampled.AudioSystem;
/**
*
* @author abel
*/
public class JugadorVirtual extends Jugador{
public JugadorVirtual(ArrayList fichas){
super(fichas);
}
public Ficha dameFicha(Ficha x){
if (x!=null)
{
for(int i=0;i<fichas.size();i++)
{Ficha f=(Ficha)fichas.get(i);
if (f.e1==x.e1||f.e1==x.e2) { try{
audio= AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/domino/ficha.wav"));
clip = AudioSystem.getClip();
clip.open(audio);
clip.start();
}catch(Exception ex){ex.printStackTrace();}
f.punta=f.e1;
return f;}
if (f.e2==x.e1||f.e2==x.e2) { try{
audio= AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/domino/ficha.wav"));
clip = AudioSystem.getClip();
clip.open(audio);
clip.start();
}catch(Exception ex){ex.printStackTrace();}
f.punta=f.e2;
return f;}
}
}
else {try{
audio= AudioSystem.getAudioInputStream(getClass().getResourceAsStream("/domino/ficha.wav"));
clip = AudioSystem.getClip();
clip.open(audio);
clip.start();
}catch(Exception ex){ex.printStackTrace();}
Ficha f=(Ficha)fichas.get(0);f.punta=f.e1;
return f; }
return null;
}
}