How can I precalculate the values before the opponent is chosen.
Well, not before the opponent is chosen but when he is chosen or directly after that.
The only way I could precalculate before the opponent is chosen is to preset all potential opponents which means if I have 32 potential opponents, I would need a minimum of 32^6 = 2,176,782,336 variables.
Yes, that also wouldn't work for all actual chapters within the match. If you did that, you would need to have that structure 32 times.
Here an example of how it would look like.
I used 3 traits, so you would end up using 3^2 = 9 variables.
The traits of the MC are A, B, and C and the traits of the opponent X, Y, and Z.
A would be the equivalent of X and all traits could be used against each other. (Means AX, AY, AZ, BX, BY, BZ, CX, CY, CZ)
The base advantage of the MC is 9 = 3, 10 = 4, 11 = 5, 12 =6, and the modifier of the opponents modifier of the advantage are 9 = - 0, 10 = -1, 11 = -2, 12 = -3
The variable "adAX" means advantage MC trait A vs. opponent trait X. (E.g. A = tricky and X = foe tricky)
(Depending on implementation there might be additional things to keep in mind but let's do this simplified version first. E.g. you need to "rechoose" the MC type before the match depending on the type you've chosen first by using link chapters to 8.2 to 8.4 before the new match.)
Code:
7.1 What kind of wrestler are you? (This is the one that sets your traits and other similar variables)
8.1 Choose your opponent from this limited set.
9.1 Choose your move.
10.1 Do you orgasm?
11.1 [...]
10.2 Go for his shorts; move = 1; Condition: adAX = 0
10.3 Go for his shorts; move = 1; Condition: adAX = 1
10.4 Go for his shorts; move = 1; Condition: adAX = 2
10.5 Go for his shorts; move = 1; Condition: adAX = 3
10.6 Go for his shorts; move = 1; Condition: adAX = 4
10.7 Go for his shorts; move = 1; Condition: adAX = 5
10.8 Go for his shorts; move = 1; Condition: adAX = 6
10.9 Twist his arm; move = 2; Condition: adBZ = 0
10.10 Twist his arm; move = 2; Condition: adBZ = 1
10.11 Twist his arm; move = 2; Condition: adBZ = 2
10.12 Twist his arm; move= 2; Condition: adBZ = 3
10.13 Twist his arm; move = 2; Condition: adBZ = 4
10.14 Twist his arm; move = 2; Condition: adBZ = 5
10.15 Twist his arm; move = 2; Condition: adBZ = 6
10.nn [more moves with results and outcomes]
9.2 Ryan; opponent = 1, X = 9, Y = 10, Z = 9; adAX - 0, adBX - 0, adCX - 0, adAY - 1, adBY - 1, adCY - 1, adAZ - 0, adBZ - 0, adCZ - 0 -> links to 9.1
9.3 Carl; opponent = 2, X = 9, Y = 10, Z = 11; adAX - 0, adBX - 0, adCX - 0, adAY - 1, adBY - 1, adCY - 1, adAZ - 2, adBZ - 2, adCZ - 2 -> links to 9.1
9.4 Chad; character = 3, X = 11, Y = 12, Z = 9; adAX - 2, adBX - 2, adCX - 2, adAY - 3, adBY - 3, adCY - 3, adAZ - 0, adBZ - 0, adCZ - 0 -> links to 9.1
8.2 Type 1; A = 9, B = 10, C = 11; adAX = 3, adAY = 3, adAZ = 3, adBX = 4, adBY = 4, adBZ = 4, adCX = 5, adCY = 5, adCZ = 5 -> links to 8.1
8.3 Type 2; A = 10, B = 11, C = 9; adAX = 4, adAY = 4, adAZ = 4, adBX = 5, adBY = 5, adBZ = 5, adCX = 3, adCY = 3, adCZ = 3 -> links to 8.1
8.4 Type 3; A = 9, B = 9, C = 12; adAX = 3, adAY = 3, adAZ = 3, adBX = 3, adBY = 3, adBZ = 3, adCX = 6, adCY = 6, adCZ = 6 -> links to 8.1
(The chapters 10.nn would also contain the description of the outcome as you mentioned and would each need a link chapter to 10.1.)
In the chapters 8.2 to 8.4, the base values of the advantage variables are set.
In the chapters 9.2 to 9.4, the modifier gets applied.
If you view it like a table with A, B, and C as columns, and X, Y, and Z as rows, then the chapters 8.n would put the same number within each cell of a single row, and the chapters 9.n would modify the numbers with the same modifier within a single column.
That way, you can precalculate all later results in these two chapter levels.
The possible outcomes of advantage variables are between 0 and 6.
If you have a difficult move, you might want to shift the scale, so you might only succeed when the value is 5 or 6, with 0 to 4 leading to different levels of failure.
If you want to temporarily change the advantage within a match, it would be no problem as long as the advantage is supposed to be "reset" after the match.
E.g. the MC tries a move "Twist his arm (A vs. X)" and fails badly. Due to the outcome (adAX = 0), the MC strained their wrist and their skill B (agility) is reduced by 1. To take that into account, you modify all advantages with B by - 1. As the pain goes away after the match, the change is only temporary. (If you do something like that, you have to take into account values below 0 (e.g. <1) and above 6 (e.g. >5))
(With this approach, you wouldn't really need the variables A, B, C, X, Y, and Z. So you would end up with [number of traits]^2 variables instead of [number of traits]*2 variables. All traits that don't have to interact with the opponent's traits can be counted separately.)
By the way, most of the traits do not change.
There is a difference in the approach if it is even possible that only one trait changes.
In that case, you can't do it directly in the Type and Opponent chapter.
So let's say the base value A, B, or C can change between matches and due to the possible change, the values can be 9, 10, 11, 12, 13, and 14.
Then you need to have one level for A with 6 chapters (for each number 8 to 14), one level for B with 6 chapters, and one level for C with 6 chapters.
After that, you choose the opponent.
If their values X, Y, and Z could change between matches, you would need to set X, Y, and Z first and then do the same as with A, B, and C.
Though I assume that you don't want to do that as you would have to keep track of all opponents' traits even after switching between them.
But if you want to go for changes like that, let me know.
I'm not sure what you mean by linear but I am guessing that my game is not linear at all.
No, that wasn't about the game being linear.
If one point more in a trait always results in one point more in the advantage, it is linear.
It wouldn't be linear if a higher difference in the trait points would lead to a higher bonus/penalty in the advantage.
E.g.
A = 12, X = 12 (difference 0) -> adAX = 3
A = 11, X = 12 (difference 1) -> adAX = 2
A = 10, X = 12 (difference 2) -> adAX = 0
A = 9, X = 12 (difference 3) -> adAX = -3
Here, the last two advantages drop down more than the difference, so it wouldn't be linear.
As noted, I guess that doesn't make much sense.