mainIine / foe-helfer-extension

FoE Helfer - Extension for chromium based browsers and Firefox ;-)
https://foe-helper.com
GNU Affero General Public License v3.0
120 stars 180 forks source link

Add fragments to production view #2636

Closed bencptest closed 1 year ago

bencptest commented 1 year ago

Add fragments to production view

outoftheline commented 1 year ago

i changed the base from master to beta, because we always merge beta into master when updating the extension.

will check your changes later :) thank you!

bencptest commented 1 year ago

OK, first time contributing here :) I actually found issues around unmotivated building logic I need to fix

AlfonZ42 commented 1 year ago

I got an error upon trying to open the productions window (including my added debug line):

type= goods ca= Úlomok z Menšia renovácia GoodsData[ca]= undefined countProducts[ca]= 2 countProductsMotivated[ca]= NaN countProductsDone[ca]= 0
merged-3rd-party-1d066424.js:16 TypeError: Cannot read property 'era' of undefined
    at Object.CalcBody (productions.js?v=3.2.6.0:1164)
    at Object.showBox (productions.js?v=3.2.6.0:921)
    at Object.ReadData (productions.js?v=3.2.6.0:254)
    at Object.init (productions.js?v=3.2.6.0:107)

I'm not sure whether it's the issue you mentioned, or due to fragment name localization, or something else.

bencptest commented 1 year ago

Can you add debug inside the if in line 1066 and print the variable "p" - we're looking for something that is not a goods name That if should prevent the fragments to be considered as goods which is causing TypeError later when the code iterates over it

AlfonZ42 commented 1 year ago

A bunch of them:

i= W_MultiAge_FallBonus21i_11050 ,buildings[i]= [name: "Zlatá úroda - úr. 9", type: "residential", …] ,p= Úlomok z Menšia renovácia
i= W_MultiAge_WIN22A11a_20276 ,buildings[i]= [name: "Tedova čokoládovňa", type: "residential", …] ,p= Úlomok z Luskáčikova strážnica
i= W_MultiAge_WIN22A11a_20276 ,buildings[i]= [name: "Tedova čokoládovňa", type: "residential", …] ,p= úlomky z Luskáčikova strážnica
i= W_MultiAge_HalloweenBonusGP22l_20482 ,buildings[i]= [name: "Tarotové karavany - úr. 12", type: "residential", …] ,p= Úlomok z Dokončiť všetky produkcie zásob
i= W_MultiAge_PAT23A9_21273 ,buildings[i]= [name: "Druidská chatrč - úr. 9", type: "residential", …] ,p= Úlomok z Vylepšenie Arcidruidskej chatrče
i= W_MultiAge_PAT23A9_21273 ,buildings[i]= [name: "Druidská chatrč - úr. 9", type: "residential", …] ,p= úlomkov z Strom vitality
i= W_MultiAge_WIN22B1_21416 ,buildings[i]= [name: "Luskáčikova strážnica", type: "residential", …] ,p= úlomky z Súprava hromadnej svojpomoci
i= W_MultiAge_PAT23D1_22827 ,buildings[i]= [name: "Strom vitality", type: "residential", …] ,p= Úlomok z Menšia renovácia
i= W_MultiAge_WILD23G_22828 ,buildings[i]= [name: "Zlatá socha pandy", type: "decoration", …] ,p= Úlomok z Vylepšenie Svätyne s pandami
i= W_MultiAge_SUM23B1_23306 ,buildings[i]= [name: "Dom kartografa", type: "residential", …] ,p= úlomky z Vylepšenie Pirátskeho trhu
i= W_MultiAge_SUM23D1_23438 ,buildings[i]= [name: "Skryté tovary", type: "residential", …] ,p= Úlomok z % posilnenie útoku pre útočnú armádu
i= W_MultiAge_SUM23A9_23678 ,buildings[i]= [name: "Pirátsky trh - úr. 9", type: "residential", …] ,p= Úlomok z % posilnenie obrany pre útočnú armádu

Also, could you please look into rebasing your changes onto beta, so the commit list is nicer? I believe git rebase --onto beta master fragments should do it in this case.

bencptest commented 1 year ago

A bunch of them:

i= W_MultiAge_FallBonus21i_11050 ,buildings[i]= [name: "Zlatá úroda - úr. 9", type: "residential", …] ,p= Úlomok z Menšia renovácia
i= W_MultiAge_WIN22A11a_20276 ,buildings[i]= [name: "Tedova čokoládovňa", type: "residential", …] ,p= Úlomok z Luskáčikova strážnica
i= W_MultiAge_WIN22A11a_20276 ,buildings[i]= [name: "Tedova čokoládovňa", type: "residential", …] ,p= úlomky z Luskáčikova strážnica
i= W_MultiAge_HalloweenBonusGP22l_20482 ,buildings[i]= [name: "Tarotové karavany - úr. 12", type: "residential", …] ,p= Úlomok z Dokončiť všetky produkcie zásob
i= W_MultiAge_PAT23A9_21273 ,buildings[i]= [name: "Druidská chatrč - úr. 9", type: "residential", …] ,p= Úlomok z Vylepšenie Arcidruidskej chatrče
i= W_MultiAge_PAT23A9_21273 ,buildings[i]= [name: "Druidská chatrč - úr. 9", type: "residential", …] ,p= úlomkov z Strom vitality
i= W_MultiAge_WIN22B1_21416 ,buildings[i]= [name: "Luskáčikova strážnica", type: "residential", …] ,p= úlomky z Súprava hromadnej svojpomoci
i= W_MultiAge_PAT23D1_22827 ,buildings[i]= [name: "Strom vitality", type: "residential", …] ,p= Úlomok z Menšia renovácia
i= W_MultiAge_WILD23G_22828 ,buildings[i]= [name: "Zlatá socha pandy", type: "decoration", …] ,p= Úlomok z Vylepšenie Svätyne s pandami
i= W_MultiAge_SUM23B1_23306 ,buildings[i]= [name: "Dom kartografa", type: "residential", …] ,p= úlomky z Vylepšenie Pirátskeho trhu
i= W_MultiAge_SUM23D1_23438 ,buildings[i]= [name: "Skryté tovary", type: "residential", …] ,p= Úlomok z % posilnenie útoku pre útočnú armádu
i= W_MultiAge_SUM23A9_23678 ,buildings[i]= [name: "Pirátsky trh - úr. 9", type: "residential", …] ,p= Úlomok z % posilnenie obrany pre útočnú armádu

Also, could you please look into rebasing your changes onto beta, so the commit list is nicer? I believe git rebase --onto beta master fragments should do it in this case.

OK this is definitely language issue, I'll need search for non English account to understand this further.

bencptest commented 1 year ago

A bunch of them:

i= W_MultiAge_FallBonus21i_11050 ,buildings[i]= [name: "Zlatá úroda - úr. 9", type: "residential", …] ,p= Úlomok z Menšia renovácia
i= W_MultiAge_WIN22A11a_20276 ,buildings[i]= [name: "Tedova čokoládovňa", type: "residential", …] ,p= Úlomok z Luskáčikova strážnica
i= W_MultiAge_WIN22A11a_20276 ,buildings[i]= [name: "Tedova čokoládovňa", type: "residential", …] ,p= úlomky z Luskáčikova strážnica
i= W_MultiAge_HalloweenBonusGP22l_20482 ,buildings[i]= [name: "Tarotové karavany - úr. 12", type: "residential", …] ,p= Úlomok z Dokončiť všetky produkcie zásob
i= W_MultiAge_PAT23A9_21273 ,buildings[i]= [name: "Druidská chatrč - úr. 9", type: "residential", …] ,p= Úlomok z Vylepšenie Arcidruidskej chatrče
i= W_MultiAge_PAT23A9_21273 ,buildings[i]= [name: "Druidská chatrč - úr. 9", type: "residential", …] ,p= úlomkov z Strom vitality
i= W_MultiAge_WIN22B1_21416 ,buildings[i]= [name: "Luskáčikova strážnica", type: "residential", …] ,p= úlomky z Súprava hromadnej svojpomoci
i= W_MultiAge_PAT23D1_22827 ,buildings[i]= [name: "Strom vitality", type: "residential", …] ,p= Úlomok z Menšia renovácia
i= W_MultiAge_WILD23G_22828 ,buildings[i]= [name: "Zlatá socha pandy", type: "decoration", …] ,p= Úlomok z Vylepšenie Svätyne s pandami
i= W_MultiAge_SUM23B1_23306 ,buildings[i]= [name: "Dom kartografa", type: "residential", …] ,p= úlomky z Vylepšenie Pirátskeho trhu
i= W_MultiAge_SUM23D1_23438 ,buildings[i]= [name: "Skryté tovary", type: "residential", …] ,p= Úlomok z % posilnenie útoku pre útočnú armádu
i= W_MultiAge_SUM23A9_23678 ,buildings[i]= [name: "Pirátsky trh - úr. 9", type: "residential", …] ,p= Úlomok z % posilnenie obrany pre útočnú armádu

Also, could you please look into rebasing your changes onto beta, so the commit list is nicer? I believe git rebase --onto beta master fragments should do it in this case.

I can't get access to account which is not English, maybe you can help me get the data I need from yours:

  1. Open devtools, go to source, navigate your way to production.js
  2. Create break point online 125 (at the for loop of ReadData()
  3. Open the production page
  4. Once break point is reached switch to console, write: console.log(JSON.stringify(d))
  5. Click on copy to copy the JSON created
AlfonZ42 commented 1 year ago

Here it is: CombinedCityMapData.zip

I don't think using reward.name as an index will work. I tried reward.id and I didn't get the error anymore -

--- a/js/web/productions/js/productions.js
+++ b/js/web/productions/js/productions.js
@@ -324,7 +324,8 @@ let Productions = {
                    let CurrentProduct = CurrentProducts[i];

                    if((CurrentProduct['type'] && CurrentProduct['type']==='genericReward') && (CurrentProduct['reward'] && CurrentProduct['reward']['subType'] && CurrentProduct['reward']['subType']==='fragment' )){
-                       let displayName = CurrentProduct['reward']['name'].replace(/[0-9]/g, '').trimStart().replace(/Fragment\b/g, 'Fragments');
+//                     let displayName = CurrentProduct['reward']['name'].replace(/^[0-9]*/, '').trimStart().replace(/Fragment\b/g, 'Fragments');
+                       let displayName = CurrentProduct['reward']['id'];
                        let rewardName = CurrentProduct['reward']['name'];
                        if (CurrentProduct['onlyWhenMotivated'] && !IsPolivated){
                            displayName = displayName+" "
bencptest commented 1 year ago

Moving to https://github.com/mainIine/foe-helfer-extension/pull/2639 for cleaner pull request

bencptest commented 1 year ago

Here it is: CombinedCityMapData.zip

I don't think using reward.name as an index will work. I tried reward.id and I didn't get the error anymore -

--- a/js/web/productions/js/productions.js
+++ b/js/web/productions/js/productions.js
@@ -324,7 +324,8 @@ let Productions = {
                  let CurrentProduct = CurrentProducts[i];

                  if((CurrentProduct['type'] && CurrentProduct['type']==='genericReward') && (CurrentProduct['reward'] && CurrentProduct['reward']['subType'] && CurrentProduct['reward']['subType']==='fragment' )){
-                     let displayName = CurrentProduct['reward']['name'].replace(/[0-9]/g, '').trimStart().replace(/Fragment\b/g, 'Fragments');
+//                       let displayName = CurrentProduct['reward']['name'].replace(/^[0-9]*/, '').trimStart().replace(/Fragment\b/g, 'Fragments');
+                     let displayName = CurrentProduct['reward']['id'];
                      let rewardName = CurrentProduct['reward']['name'];
                      if (CurrentProduct['onlyWhenMotivated'] && !IsPolivated){
                          displayName = displayName+" "

Non English should be fixed on new MR - https://github.com/mainIine/foe-helfer-extension/pull/2639