Browse Source

孵育盘循环使用测试卡位

tags/v0
sige 1 year ago
parent
commit
766016b893
  1. 17
      src/main/java/com/iflytop/a800/device/Incubator.java

17
src/main/java/com/iflytop/a800/device/Incubator.java

@ -9,9 +9,12 @@ import java.util.Map;
public class Incubator { public class Incubator {
// 槽位 // 槽位
private final List<IncubatorSlot> slots; private final List<IncubatorSlot> slots;
// 槽位起始索引
private Integer slotStartIndex = 0;
// 构造函数 // 构造函数
public Incubator() { public Incubator() {
this.slotStartIndex = 0;
this.slots = new ArrayList<>(); this.slots = new ArrayList<>();
for ( int i = 0; i < 20; i++ ) { for ( int i = 0; i < 20; i++ ) {
var slot = new IncubatorSlot(); var slot = new IncubatorSlot();
@ -20,14 +23,20 @@ public class Incubator {
} }
} }
public void lock() {}
public void unlock() {}
// 推送新卡片 // 推送新卡片
public IncubatorSlot pushNewCard(TestCard card) { public IncubatorSlot pushNewCard(TestCard card) {
IncubatorSlot slot = null; IncubatorSlot slot = null;
for ( var s : this.slots ) {
if ( s.card == null ) {
slot = s;
break;
for ( int i=0; i<20; i++ ) {
var tmpSlot = this.slots.get(this.slotStartIndex);
this.slotStartIndex = (this.slotStartIndex + 1) % 20;
if ( tmpSlot.card != null ) {
continue ;
} }
slot = tmpSlot;
break;
} }
if ( slot == null ) { if ( slot == null ) {
throw new RuntimeException("无可用孵育盘槽位"); throw new RuntimeException("无可用孵育盘槽位");

Loading…
Cancel
Save