⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movefleettransaction.java

📁 Java mulitplayer strategy game. Adaptation of KDE Galaxy Conquest. (rules are changed - but still th
💻 JAVA
字号:
/*
 * MoveFleetTransaction.java
 *
 * Created on 4 pa焏ziernik 2005, 00:38
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package net.sf.jawp.game.system.transaction;

import java.util.Date;

import net.sf.jawp.api.service.JAWPGameService;
import net.sf.jawp.game.domain.JAWPGameWorldDO;
import net.sf.jawp.game.domain.JAWPGameWorldRO;
import net.sf.jawp.game.domain.MoveOrder;
import net.sf.jawp.game.domain.PlanetDO;
import net.sf.jawp.gf.system.GameSystemCommand;
import net.sf.jawp.gf.system.RootSystem;
import net.sf.jawp.util.Log;

/**
 *
 * @author jarek
 */
public class MoveFleetTransaction extends GameSystemCommand<Void, 
		JAWPGameWorldDO, JAWPGameWorldRO, JAWPGameService>
{
	private static final long serialVersionUID = 1L;
	
	private static final Log LOG = Log.getLog(MoveFleetTransaction.class );
	
	private final long gameKey;
	
	private final long fromPlanetKey;
	
	private final long toPlanetKey;
	
	private final int size;
	/** Creates a new instance of MoveFleetTransaction */
	public MoveFleetTransaction(final long game, final long from, final long to, final int sz)
	{
		this.gameKey = game;
		this.fromPlanetKey = from;
		this.toPlanetKey = to;
		this.size = sz;
	}

	public Void perform(final RootSystem<JAWPGameWorldDO, JAWPGameWorldRO, JAWPGameService> system,
				final Date time)
	{
		final long startTime = System.currentTimeMillis();
		final JAWPGameWorldDO game = system.findGame(gameKey );
		final PlanetDO fromPlanet = game.findPlanetDO( fromPlanetKey);
		final PlanetDO toPlanet = game.findPlanetDO( toPlanetKey);
		if ( fromPlanet.getHomeFleetSize() >= size )
		{
			final MoveOrder order = new MoveOrder(fromPlanet, toPlanet, size);
			game.addMoveOrder( order );
		}
		assert LOG.debug( (System.currentTimeMillis() - startTime) + "ms for server move transaction" );
		return null;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -