Combat Passage Sometimes Not Showing Information

I made a combat system a little while ago and just “finished” on a character. I was very wrong, it seems like this specific passage every now and then just skips your turn. No math is made, no text is shown. It just successfully checks if the enemy has more than 0 Health and just continues. Nothing shows up except to continue.

<table align="center">

	 <tr>
     
     	<td>
        
        	[img[images/Voxiremise epe.jpg]]
            <br>
            HP: $SBHealth/100
            <tr>
			<td>Basic</td>
            <td></td><td></td><td></td><td></td>
            <td>Advanced</td>
            <td></td><td></td><td></td><td></td>
            <td width="150%">Ultimate</td>
            </tr>

		</td>
        
        <td width="60%" align="center">
        <!--Text and math goes here-->
        
        <<set _ATKDice to random(1,20)>>

		<<if _ATKDice + $ATKBonus < $EArmorClass>>
		You enter a state of rage, wildly attacking every enemy in battle, but they dodged.

		<<elseif _ATKDice + 4 >= $EArmorClass>>
		<<set _FightDamage to random(10,35)>>
		<<set $EHP to $EHP - _FightDamage>>

		You enter a state of rage as you wildly attack the stone rat 
        with anything you can think of, dealing _FightDamage Damage, 
        the stone rat has $EHP Health left.
		<</if>>
		<br>
        
		<<if $EHP > 0>>
		[[Continue Thy Battle->NEW Stone Rat EATK V]]
        
		<<elseif $EHP <= 0>>
		<<set _EnergyGain to random(5,10)>>
		<<set $SBEnergy to $SBEnergy+_EnergyGain+5>>
		<<set _CoinGain to random(5,15)>>
		<<set $SBCoins to $SBCoins + _CoinGain>>
		You hath thlaughtered thy shtone rat, gaining _EnergyGain 
        Energy and _CoinGain Coins.
		<br> [[Restart->NEW Combat Variables]]
		<</if>>
		</td>
        
        <td>
        
        	[img[images/picturenotfound.jpg]]
            <br>
            HP: $EHP/50
		
        </td>
        
	</tr>
    
</table>

This is the code I have written, please explain why it doesn’t work I have not been able to figure this out. I cannot recreate this problem for the life of me.

One thing I notice is that in the elseifbelow there’s a hardcoded value (4), which in certain cases could result in no branch being run. Would an else block be sufficient if you have just two possible outcomes?

Wow I didn’t even realize that… the 4 is not supposed to be there, that’s probably why I was having all of these issues.

In terms of an else block I’m not 100% sure since I need to do extra math with the $ATKBonus variable. I am a beginner so I just do elseif since I’m a little paranoid :sweat_smile:.

Having complementary expressions in if and elseif is error-prone since you need to maintain them in sync.

If you must do it, I’d recommend having an else block to catch the mistakes and print something of the “ERROR: this should never happen” sort.

Good to know, thanks!

There is a structural issue in your Table related HTML.

If we comment out the images, assignments, conditionals, and variable value displaying code we are left with…

<table align="center">
	<tr>
		<td>
			<!-- Image & HP -->
			<tr>
				<td>Basic</td>
				<td></td><td></td><td></td><td></td>
				<td>Advanced</td>
				<td></td><td></td><td></td><td></td>
				<td width="150%">Ultimate</td>
			</tr>
		</td>
		<td width="60%" align="center">
			<!--Text and math goes here-->

			<!-- Assignments and conditional content -->
		</td>
		<td>       
			<!-- Image & HP -->
		</td>
	</tr>
</table>

…which has a table-row <tr> definition inside the body of the 1st table-cell <td>, and that’s an issue because elements should be direct children of either <table> or <thead> or <tbody> or <tfoot>.

It is unclear if you are:

A: actually trying to embed a table within the body of the 1st cell, in which the structure should be…

<table align="center">
	<tr>
		<td>
			<!-- Image & HP -->
			<table>
				<tr>
					<td>Basic</td>
					<td></td><td></td><td></td><td></td>
					<td>Advanced</td>
					<td></td><td></td><td></td><td></td>
					<td width="150%">Ultimate</td>
				</tr>
			</table>
		</td>
		<td width="60%" align="center">
			<!--Text and math goes here-->

			<!-- Assignments and conditional content -->
		</td>
		<td>       
			<!-- Image & HP -->
		</td>
	</tr>
</table>

B: Trying to define the column “headers” for the overall table, in which case the following might be a better solution…

<table align="center">
	<tr>
		<td>Basic</td>
		<td></td><td></td><td></td><td></td>
		<td>Advanced</td>
		<td></td><td></td><td></td><td></td>
		<td width="150%">Ultimate</td>
	</tr>
	<tr>
		<td>
			<!-- Image & HP -->
		</td>
		<td width="60%" align="center">
			<!--Text and math goes here-->

			<!-- Assignments and conditional content -->
		</td>
		<td>       
			<!-- Image & HP -->
		</td>
	</tr>
</table>

C: Something else entirely…

note: Because the web-browser knows that the structure of your original code is invalid, it will try to “fix” it when it renders that structure. However, the “fix” may not be the same for all web-browser brands, as each can have it’s own ideal of how to do that fixing, and the results can be quite “interesting”.

For a header <th> is preferrable to <td>

Interesting… I had no idea about this I just followed a tutorial and learned what the tags meant.

I’m just trying to get a format like this where we have the Image on the left, health (and any extra variables), a row below it have the links of “Basic” “Advanced” and “Ultimates”, text & math in the center, and the enemy’s image and health on the right.

Tables are not really the right way to approach layout these days, because while they provide a quick and easy way to do columns, they can’t adapt to smaller screen sizes (e.g. someone playing on mobile).

Take a look at flex and grid in CSS as an alternative designed to do the same layout jobs as tables but with added flexibility.

I’ll look into it, thanks!