用c语言编写了一个五子棋程序,人机对战偶尔运行到一半会卡死,是什么问题

2025-02-22 12:08:34
推荐回答(1个)
回答1:

/**
 * 
 */
package com.efounder.gwt.action;
import java.util.HashMap;
import java.util.Map;
import poc.shared.annotations.reflection.ClassForNameAble;
import com.efounder.builder.meta.bizmodel.SYS_MDL_CTN;
import com.efounder.gwt.action.utils.ActionUtils;
import com.efounder.gwt.form.application.util.FormScriptUtil;
import com.efounder.gwt.form.base.ActionComponent;
import com.efounder.gwt.form.base.DataSetComponent;
import com.efounder.gwt.model.FilterDataSet;
import com.efounder.gwt.model.FormModel;
import com.gwtent.reflection.client.Reflectable;
/**
 * 创建单据分录或明细
 * @author xiewanzhi
 * @datetime 2015年3月30日 上午9:38:34
 */
@ClassForNameAble
@Reflectable
public class FormAddItemAction extends ActionComponent implements IFormAction{
public FormAddItemAction() {
super.setActionText("增加");
}
private FormModel formModel = null;
/**
 * 获取表单模型
 * @return
 */
public FormModel getFormModel() {
return formModel;
}
/**
 * 设置表单模型
 * @param formModel
 */
public void setFormModel(FormModel formModel) {
this.formModel = formModel;
}
private String CTN_ID = null;
/**
 * 内容id
 * @return
 */
public String getCTN_ID() {
return CTN_ID;
}
/**
 * 设置内容id
 * @param cTN_ID
 */
public void setCTN_ID(String cTN_ID) {
CTN_ID = cTN_ID;
}
private String ctnType = SYS_MDL_CTN._BIZ_CTN_TYPE_JIDS_;
/**
 * 分录类型:分录(SYS_MDL_CTN._BIZ_CTN_TYPE_JIDS_)还是辅助分录(SYS_MDL_CTN._BIZ_CTN_TYPE_JPDS_)
 * @return
 */
public String getCtnType() {
return ctnType;
}
/**
 * 分录类型:分录和明细
 * @param ctnType
 */
public void setCtnType(String ctnType) {
this.ctnType = ctnType;
}
/**
 * 数据集组件,FormModel,过滤器FilterDataSet等
 */
private DataSetComponent dataSetComponent = null;
/**
 * 数据集组件,FormModel,过滤器FilterDataSet等
 * @return
 */
public DataSetComponent getDataSetComponent() {
return dataSetComponent;
}
/**
 * 设置数据集组件,FormModel,过滤器FilterDataSet等
 * @param dataSetComponent
 */
public void setDataSetComponent(DataSetComponent dataSetComponent) {
this.dataSetComponent = dataSetComponent;
}
/**
 * 执行添加分录操作
 */
@Override
public Object doAction() {
// 检查模型
assert formModel != null : "添加分录action没有关联表单模型FormModel";
// 检查内容ID
assert CTN_ID != null && !"".equals(CTN_ID) : "添加分录action没有设置内容id";
Map args = new HashMap();
//执行脚本
if("0".equals(FormScriptUtil.executeCompScripts(this,scriptContext, "beforeAdd", this, args))){
return null;
}
// 增加分录
if ( SYS_MDL_CTN._BIZ_CTN_TYPE_JIDS_.equals(ctnType) ) {
if ( dataSetComponent == null ) {
formModel.setCopy(isCopyRow);
formModel.createItem(CTN_ID, isAppend, null);
}
else {
// add by LiChao 使用数据集过滤集时创建一条分录
if( dataSetComponent instanceof FilterDataSet ){
formModel.setCopy(isCopyRow);
((FilterDataSet) dataSetComponent).createItem(CTN_ID);
}else
{
formModel.setCopy(isCopyRow);
((FormModel)dataSetComponent).createItem(CTN_ID, isAppend, null);
}
}
}
// 添加辅助分录
else if ( SYS_MDL_CTN._BIZ_CTN_TYPE_JPDS_.equals(ctnType) ) {
if ( dataSetComponent == null ) {
formModel.setCopy(isCopyRow);
//modified by LiChoa 执行添加辅助分录明细动作
formModel.createPart(CTN_ID);
} else {
// add by LiChao 使用数据集过滤集时创建一条明细
if( dataSetComponent instanceof FilterDataSet ){
((FilterDataSet) dataSetComponent).createPart(CTN_ID);
}else{
formModel.setCopy(isCopyRow);
((FormModel)dataSetComponent).createPart(CTN_ID, isAppend,"");
}
}
}
//执行脚本
FormScriptUtil.executeCompScripts(this,scriptContext, "endAdd", this, args);
return null;
}
/**
 * 更新button状态
 */
@Override
public void doUpdate() {
if ( formModel == null ) {
this.setEnabled(false);
return;
}
// 通常单据提交之后,增加按钮不可用
if ( formModel.isEditing() ) {
this.setEnabled(true);
} else {
this.setEnabled(false);
}
//根据属性配置检查
this.setEnabled(ActionUtils.canEnable(this));
//formmodel可编辑时设置该action不可编辑  chenkai2016年10月24日
if (!canEdit) {
this.setEnabled(false);
}
//enabled = ActionUtils.canEnable(this);
super.doUpdate();
}
private boolean isCopyRow = false;
/**
 * 是否复制上一行
 * @return
 */
public boolean isCopyRow() {
return isCopyRow;
}
// baiguanghong 获取是否复制上一行
public boolean getIsCopyRow() {
return isCopyRow;
}
public void setIsCopyRow(boolean isCopyRow) {
this.isCopyRow = isCopyRow;
}
private boolean isAppend = false;
/**
 * 是否追加。默认false;
 * @return
 */
public boolean isAppend() {
return isAppend;
}
public void setIsAppend(boolean isAppend) {
this.isAppend = isAppend;
}
boolean canEdit = true;
/**
 * 设置不可编辑 chenkai2016年10月24日
 * @param canEdit
 */
public void setCanEdit(boolean canEdit) {
this.canEdit = canEdit;
}
@Override
public void register() {
super.register();
registerAciton();
}
public native void registerAciton() /*-{
this.getActionText = this.@com.efounder.gwt.action.FormAddItemAction::getActionText();
this.setCanEdit = this.@com.efounder.gwt.action.FormAddItemAction::setCanEdit(Z);
this.setFormModel = this.@com.efounder.gwt.action.FormAddItemAction::setFormModel(Lcom/efounder/gwt/model/FormModel;);
this.setDataSetComponent = this.@com.efounder.gwt.action.FormAddItemAction::setDataSetComponent(Lcom/efounder/gwt/form/base/DataSetComponent;);
}-*/;
}