Prechádzať zdrojové kódy

Added some try-catches to readme sample

KeyMasterOfGozer 3 mesiacov pred
rodič
commit
26f9212da5
1 zmenil súbory, kde vykonal 36 pridanie a 31 odobranie
  1. 36 31
      README.md

+ 36 - 31
README.md

@@ -276,19 +276,19 @@ for (var i = 0; i < cards.length; i++) {
 ```javascript
 buyThreshold = {};
 buyThreshold["2000"] = 1000;
-buyThreshold["350"] = 155;
+buyThreshold["350"] = 200;
 buyThreshold["250"] = 100;
-buyThreshold["200"] =  65;
+buyThreshold["200"] =  75;
 buyThreshold["150"] =  85;
 buyThreshold["115"] =  60;
 buyThreshold["75"]  =  25;
 buyThreshold["50"]  =  18;
 buyThreshold["40"]  =  25;
-buyThreshold["20"]  =  15;
-buyThreshold["15"]  =   8;
+buyThreshold["20"]  =  13;
+buyThreshold["15"]  =   7;
 buyThreshold["10"]  =   5;
-buyThreshold["4"]   =   6;
-buyThreshold["3"]   =   1;
+buyThreshold["4"]   =   4;
+buyThreshold["3"]   =   2;
 buyThreshold["2"]   =   1;
 buyThreshold["1"]   =   1;
 playerStock=[];
@@ -318,7 +318,7 @@ for (var i = 0; i < playerCards.length; i++) {
         }catch(err){console.log('No Status, or Normal Card : '+cardNum.toString());}
         playerStock[cardNum]=stock;
     }
-    }catch(err){console.log('Error on Card : '+cardNum.toString());}
+    }catch(err){console.log('Error on Card : '+i.toString());}
 };
 cards=document.getElementsByClassName('wrapper-market-card');
 for (var i = 0; i < cards.length; i++) {
@@ -326,31 +326,36 @@ for (var i = 0; i < cards.length; i++) {
     cardVal = parseInt(cards.item(i).getElementsByClassName('score-card')[0].outerText);
     cardCost = parseInt(cards.item(i).getElementsByClassName('cost')[0].outerText);
     cardPPG = cardVal/cardCost;
-    if (playerStock[cardNum].status != "NORMAL"){
-        HTMLText=playerStock[cardNum].status + " +"
-    }else{HTMLText=""}
-    HTMLText = "Stock: " + HTMLText + playerStock[cardNum].extra;
-    HTMLText = HTMLText+"<br/>"+
-            "Points/<img src='https://play.boobylegends.com/wp-content/themes/child-roulette/img/gem.png' style='height:22px'>:<br/>" + cardPPG.toFixed(2);
-    innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
-    var extraInfo = innerCard.getElementsByClassName('extraInfo')[0];
-    if (extraInfo){extraInfo.innerHTML = HTMLText}
-    else {
-        let extraInfoDiv = document.createElement('div');
-        extraInfoDiv.classList.add('extraInfo');
-        extraInfoDiv.innerHTML = HTMLText;
-        extraInfoDiv.setAttribute("align", "center");
-        innerCard.appendChild(extraInfoDiv);
+    try{
+        if (playerStock[cardNum].status != "NORMAL"){
+            HTMLText=playerStock[cardNum].status + " +"
+        }else{HTMLText=""}
+        HTMLText = "Stock: " + HTMLText + playerStock[cardNum].extra;
+        HTMLText = HTMLText+"<br/>"+
+                "Points/<img src='https://play.boobylegends.com/wp-content/themes/child-roulette/img/gem.png' style='height:22px'>:<br/>" + cardPPG.toFixed(2);
+        innerCard = cards.item(i).getElementsByClassName('inner-market-card')[0];
+        var extraInfo = innerCard.getElementsByClassName('extraInfo')[0];
+        if (extraInfo){extraInfo.innerHTML = HTMLText}
+        else {
+            let extraInfoDiv = document.createElement('div');
+            extraInfoDiv.classList.add('extraInfo');
+            extraInfoDiv.innerHTML = HTMLText;
+            extraInfoDiv.setAttribute("align", "center");
+            innerCard.appendChild(extraInfoDiv);
+            }
+        if (playerStock[cardNum].status == 'CRYSTAL'){
+            cards.item(i).style.setProperty('Display','None');
         }
-    if (playerStock[cardNum].status == 'CRYSTAL'){
-        cards.item(i).style.setProperty('Display','None');
-    }
-    /*if (cardPPG < 2){
-        cards.item(i).style.setProperty('Display','None');
-    }*/
-    if (cardCost > buyThreshold[cardVal.valueOf()]){
-        cards.item(i).style.setProperty('Display','None');
-    }
+        /*if (cardPPG < 2){
+            cards.item(i).style.setProperty('Display','None');
+        }*/
+        /*if (cardCost > buyThreshold[cardVal.valueOf()]){
+            cards.item(i).style.setProperty('Display','None');
+        }*/
+        if ((cardCost > buyThreshold[cardVal.valueOf()])&&(cardPPG < 2)){
+            cards.item(i).style.setProperty('Display','None');
+        }
+    }catch(err){console.log('Error on Card : '+i.toString());}
 } //filter Market for good buys for needed cards
 ```