Fix turn management
This commit is contained in:
		@@ -165,6 +165,17 @@ export class Hero6Combat extends Combat {
 | 
				
			|||||||
    return false
 | 
					    return false
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* -------------------------------------------- */
 | 
				
			||||||
 | 
					  nextTurn() {
 | 
				
			||||||
 | 
					    let nbC = this.combatants.filter(c => c.initiative > 0).length
 | 
				
			||||||
 | 
					    //console.log("Next turn called....", this.turn, nbC)
 | 
				
			||||||
 | 
					    if (this.turn < nbC-1) {
 | 
				
			||||||
 | 
					      super.nextTurn()
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      this.nextRound()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* -------------------------------------------- */
 | 
					  /* -------------------------------------------- */
 | 
				
			||||||
  async nextRound() {
 | 
					  async nextRound() {
 | 
				
			||||||
    let hasCombatants = false
 | 
					    let hasCombatants = false
 | 
				
			||||||
@@ -173,9 +184,8 @@ export class Hero6Combat extends Combat {
 | 
				
			|||||||
    let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
 | 
					    let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
 | 
				
			||||||
    let turnData = this.getFlag("world", "hero6-turn-data")
 | 
					    let turnData = this.getFlag("world", "hero6-turn-data")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    console.log("Next round called....", nextRound, turnData)
 | 
					    //console.log("Next round called....", nextRound, turnData)
 | 
				
			||||||
    while (!hasCombatants) {
 | 
					    while (!hasCombatants) {
 | 
				
			||||||
      turn = turn; // Preserve the fact that it's no-one's turn currently.
 | 
					 | 
				
			||||||
      if (this.settings.skipDefeated && (turn !== null)) {
 | 
					      if (this.settings.skipDefeated && (turn !== null)) {
 | 
				
			||||||
        turn = this.turns.findIndex(t => !t.isDefeated);
 | 
					        turn = this.turns.findIndex(t => !t.isDefeated);
 | 
				
			||||||
        if (turn === -1) {
 | 
					        if (turn === -1) {
 | 
				
			||||||
@@ -186,7 +196,7 @@ export class Hero6Combat extends Combat {
 | 
				
			|||||||
      advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime;
 | 
					      advanceTime = Math.max(this.turns.length - this.turn, 0) * CONFIG.time.turnTime;
 | 
				
			||||||
      advanceTime += CONFIG.time.roundTime;
 | 
					      advanceTime += CONFIG.time.roundTime;
 | 
				
			||||||
      nextRound = nextRound + 1;
 | 
					      nextRound = nextRound + 1;
 | 
				
			||||||
      console.log("Next round called....2", nextRound, turnData)
 | 
					      //console.log("Next round called....2", nextRound, turnData)
 | 
				
			||||||
      turnData = this.getFlag("world", "hero6-turn-data")
 | 
					      turnData = this.getFlag("world", "hero6-turn-data")
 | 
				
			||||||
      if (!turnData) {
 | 
					      if (!turnData) {
 | 
				
			||||||
        turnData = { turnNumber: 0, segmentNumber: 12 }
 | 
					        turnData = { turnNumber: 0, segmentNumber: 12 }
 | 
				
			||||||
@@ -201,11 +211,11 @@ export class Hero6Combat extends Combat {
 | 
				
			|||||||
      await this.setFlag("world", "hero6-turn-data", turnData)
 | 
					      await this.setFlag("world", "hero6-turn-data", turnData)
 | 
				
			||||||
      this.turnNumber = turnData.turnNumber;
 | 
					      this.turnNumber = turnData.turnNumber;
 | 
				
			||||||
      this.segmentNumber = turnData.segmentNumber;
 | 
					      this.segmentNumber = turnData.segmentNumber;
 | 
				
			||||||
      console.log("Next round called....3", nextRound, turnData)
 | 
					      //console.log("Next round called....3", nextRound, turnData)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Re-compute init of actors
 | 
					      // Re-compute init of actors
 | 
				
			||||||
      hasCombatants = await this.rebuildInitiative()
 | 
					      hasCombatants = await this.rebuildInitiative()
 | 
				
			||||||
      console.log("Going round....", nextRound, hasCombatants)
 | 
					      //console.log("Going round....", nextRound, hasCombatants)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Update the document, passing data through a hook first
 | 
					    // Update the document, passing data through a hook first
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,14 +91,14 @@
 | 
				
			|||||||
  "styles": [
 | 
					  "styles": [
 | 
				
			||||||
    "styles/simple.css"
 | 
					    "styles/simple.css"
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  "version": "10.0.47",
 | 
					  "version": "10.0.48",
 | 
				
			||||||
  "compatibility": {
 | 
					  "compatibility": {
 | 
				
			||||||
    "minimum": "10",
 | 
					    "minimum": "10",
 | 
				
			||||||
    "verified": "11"
 | 
					    "verified": "11"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "title": "Hero System v6 for FoundrtVTT (Official)",
 | 
					  "title": "Hero System v6 for FoundrtVTT (Official)",
 | 
				
			||||||
  "manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/raw/branch/main/system.json",
 | 
					  "manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/raw/branch/main/system.json",
 | 
				
			||||||
  "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.47.zip",   
 | 
					  "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.48.zip",   
 | 
				
			||||||
  "url": "https://www.uberwald.me/gitea/uberwald/",
 | 
					  "url": "https://www.uberwald.me/gitea/uberwald/",
 | 
				
			||||||
  "background": "images/ui/hero6_welcome_page.webp",
 | 
					  "background": "images/ui/hero6_welcome_page.webp",
 | 
				
			||||||
  "id": "fvtt-hero-system-6"
 | 
					  "id": "fvtt-hero-system-6"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user