mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- CheckStyle.
This commit is contained in:
@@ -431,7 +431,7 @@ public class QuestDataIO {
|
||||
}
|
||||
GameFormatQuest res = new GameFormatQuest(name, allowedSets, bannedCards);
|
||||
try {
|
||||
if ( StringUtils.isNotEmpty(unlocksUsed)) {
|
||||
if (StringUtils.isNotEmpty(unlocksUsed)) {
|
||||
setFinalField(GameFormatQuest.class, "unlocksUsed", res, Integer.parseInt(unlocksUsed));
|
||||
}
|
||||
setFinalField(GameFormatQuest.class, "allowUnlocks", res, canUnlock);
|
||||
|
||||
@@ -80,10 +80,13 @@ public class ReadPriceList {
|
||||
|
||||
List<String> lines = FileUtil.readFile(file);
|
||||
for (String line : lines) {
|
||||
if ( line.trim().length() == 0 ) break;
|
||||
if (line.trim().length() == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (line.startsWith(ReadPriceList.COMMENT))
|
||||
if (line.startsWith(ReadPriceList.COMMENT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] s = line.split("=");
|
||||
final String name = s[0].trim();
|
||||
|
||||
@@ -39,11 +39,11 @@ import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
*
|
||||
* @author Agetian
|
||||
*/
|
||||
public class AudioClip implements IAudioClip{
|
||||
public class AudioClip implements IAudioClip {
|
||||
private final Clip clip;
|
||||
private final int SOUND_SYSTEM_DELAY = 30;
|
||||
|
||||
private final static String PathToSound = "res/sound";
|
||||
private static final String PathToSound = "res/sound";
|
||||
|
||||
public static boolean fileExists(String fileName) {
|
||||
File fSound = new File(PathToSound, fileName);
|
||||
@@ -52,8 +52,9 @@ public class AudioClip implements IAudioClip{
|
||||
|
||||
public AudioClip(final String filename) {
|
||||
File fSound = new File(PathToSound, filename);
|
||||
if ( !fSound.exists() )
|
||||
if (!fSound.exists()) {
|
||||
throw new IllegalArgumentException("Sound file " + fSound.toString() + " does not exist, cannot make a clip of it");
|
||||
}
|
||||
|
||||
try {
|
||||
AudioInputStream stream = AudioSystem.getAudioInputStream(fSound);
|
||||
@@ -74,8 +75,9 @@ public class AudioClip implements IAudioClip{
|
||||
}
|
||||
|
||||
public final void play() {
|
||||
if (null == clip)
|
||||
if (null == clip) {
|
||||
return;
|
||||
}
|
||||
clip.setMicrosecondPosition(0);
|
||||
try {
|
||||
Thread.sleep(SOUND_SYSTEM_DELAY);
|
||||
@@ -86,8 +88,9 @@ public class AudioClip implements IAudioClip{
|
||||
}
|
||||
|
||||
public final void loop() {
|
||||
if (null == clip)
|
||||
if (null == clip) {
|
||||
return;
|
||||
}
|
||||
clip.setMicrosecondPosition(0);
|
||||
try {
|
||||
Thread.sleep(SOUND_SYSTEM_DELAY);
|
||||
@@ -98,14 +101,16 @@ public class AudioClip implements IAudioClip{
|
||||
}
|
||||
|
||||
public final void stop() {
|
||||
if (null == clip)
|
||||
if (null == clip) {
|
||||
return;
|
||||
}
|
||||
clip.stop();
|
||||
}
|
||||
|
||||
public final boolean isDone() {
|
||||
if (null == clip)
|
||||
if (null == clip) {
|
||||
return false;
|
||||
}
|
||||
return !clip.isRunning();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ import forge.game.event.SpellResolvedEvent;
|
||||
import forge.game.event.TokenCreatedEvent;
|
||||
|
||||
/**
|
||||
* This class is in charge of converting any forge.game.event.Event to a SoundEffectType
|
||||
* This class is in charge of converting any forge.game.event.Event to a SoundEffectType.
|
||||
*
|
||||
*/
|
||||
public class EventVisualizer {
|
||||
|
||||
final static Map<Class<?>, SoundEffectType> matchTable = new HashMap<Class<?>, SoundEffectType>();
|
||||
static final Map<Class<?>, SoundEffectType> matchTable = new HashMap<Class<?>, SoundEffectType>();
|
||||
|
||||
public EventVisualizer() {
|
||||
matchTable.put(CounterAddedEvent.class, SoundEffectType.AddCounter);
|
||||
@@ -113,7 +113,9 @@ public class EventVisualizer {
|
||||
// if there's a specific effect for this particular card, play it and
|
||||
// we're done.
|
||||
SoundEffectType specialEffect = getSpecificCardEffect(source);
|
||||
if( specialEffect != null ) return specialEffect;
|
||||
if (specialEffect != null) {
|
||||
return specialEffect;
|
||||
}
|
||||
|
||||
if (source.isCreature() && source.isArtifact()) {
|
||||
return SoundEffectType.ArtifactCreature;
|
||||
@@ -160,7 +162,9 @@ public class EventVisualizer {
|
||||
// if there's a specific effect for this particular card, play it and
|
||||
// we're done.
|
||||
SoundEffectType specialEffect = getSpecificCardEffect(land);
|
||||
if( specialEffect != null ) return specialEffect;
|
||||
if (specialEffect != null) {
|
||||
return specialEffect;
|
||||
}
|
||||
|
||||
|
||||
final List<SpellAbility> manaProduced = land.getManaAbility();
|
||||
|
||||
@@ -4,15 +4,15 @@ package forge.sound;
|
||||
public class NoSoundClip implements IAudioClip {
|
||||
|
||||
@Override
|
||||
public void play() {}
|
||||
public void play() { }
|
||||
@Override
|
||||
public boolean isDone() { return false; }
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() {}
|
||||
public void stop() { }
|
||||
|
||||
@Override
|
||||
public void loop() {}
|
||||
public void loop() { }
|
||||
|
||||
}
|
||||
@@ -15,18 +15,19 @@ import forge.properties.ForgePreferences.FPref;
|
||||
*/
|
||||
public class SoundSystem {
|
||||
|
||||
private final static IAudioClip emptySound = new NoSoundClip();
|
||||
private final static Map<SoundEffectType, IAudioClip> loadedClips = new EnumMap<SoundEffectType, IAudioClip>(SoundEffectType.class);
|
||||
private static final IAudioClip emptySound = new NoSoundClip();
|
||||
private static final Map<SoundEffectType, IAudioClip> loadedClips = new EnumMap<SoundEffectType, IAudioClip>(SoundEffectType.class);
|
||||
|
||||
private final EventVisualizer visualizer = new EventVisualizer();
|
||||
|
||||
protected IAudioClip fetchResource(SoundEffectType type) {
|
||||
|
||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS))
|
||||
if (!Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_SOUNDS)) {
|
||||
return emptySound;
|
||||
}
|
||||
|
||||
IAudioClip clip = loadedClips.get(type);
|
||||
if ( null == clip ) { // cache miss
|
||||
if (null == clip) { // cache miss
|
||||
String resource = type.getResourceFileName();
|
||||
clip = AudioClip.fileExists(resource) ? new AudioClip(resource) : emptySound;
|
||||
loadedClips.put(type, clip);
|
||||
@@ -71,12 +72,15 @@ public class SoundSystem {
|
||||
@Subscribe
|
||||
public void receiveEvent(Event evt) {
|
||||
SoundEffectType effect = visualizer.getSoundForEvent(evt);
|
||||
if ( null == effect ) return;
|
||||
if (null == effect) {
|
||||
return;
|
||||
}
|
||||
boolean isSync = visualizer.isSyncSound(effect);
|
||||
if ( isSync )
|
||||
if (isSync) {
|
||||
playSync(effect);
|
||||
else
|
||||
} else {
|
||||
play(effect);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user