kolmafia / kolmafia

@@ -43,7 +43,7 @@
Loading
43 43
  private FamiliarData changeTo;
44 44
  private final AdventureResult item;
45 45
  private final boolean locking;
46 -
  private boolean enthrone, bjornify;
46 +
  private boolean enthrone, bjornify, stealItem;
47 47
48 48
  public FamiliarRequest() {
49 49
    super("familiar.php");
@@ -52,9 +52,14 @@
Loading
52 52
    this.locking = false;
53 53
    this.enthrone = false;
54 54
    this.bjornify = false;
55 +
    this.stealItem = true;
55 56
  }
56 57
57 58
  public FamiliarRequest(final FamiliarData changeTo) {
59 +
    this(changeTo, true);
60 +
  }
61 +
62 +
  public FamiliarRequest(final FamiliarData changeTo, boolean stealItem) {
58 63
    super("familiar.php");
59 64
60 65
    this.changeTo = changeTo == null ? FamiliarData.NO_FAMILIAR : changeTo;
@@ -62,6 +67,7 @@
Loading
62 67
    this.locking = false;
63 68
    this.enthrone = false;
64 69
    this.bjornify = false;
70 +
    this.stealItem = stealItem;
65 71
66 72
    if (this.changeTo == FamiliarData.NO_FAMILIAR) {
67 73
      this.addFormField("action", "putback");
@@ -80,6 +86,7 @@
Loading
80 86
    this.locking = false;
81 87
    this.enthrone = false;
82 88
    this.bjornify = false;
89 +
    this.stealItem = true;
83 90
84 91
    if (this.item != EquipmentRequest.UNEQUIP) {
85 92
      this.addFormField("action", "equip");
@@ -100,6 +107,7 @@
Loading
100 107
    this.locking = true;
101 108
    this.enthrone = false;
102 109
    this.bjornify = false;
110 +
    this.stealItem = true;
103 111
    this.addFormField("ajax", "1");
104 112
  }
105 113
@@ -281,13 +289,16 @@
Loading
281 289
282 290
    super.run();
283 291
284 -
    // If we didn't have a familiar before or don't have one now,
292 +
    // If we didn't have a familiar before,
293 +
    // don't have one now,
294 +
    // or have chosen not to change equipment
285 295
    // leave equipment alone.
286 296
287 297
    if (this.enthrone
288 298
        || this.bjornify
289 299
        || familiar == FamiliarData.NO_FAMILIAR
290 -
        || this.changeTo == FamiliarData.NO_FAMILIAR) {
300 +
        || this.changeTo == FamiliarData.NO_FAMILIAR
301 +
        || !this.stealItem) {
291 302
      return;
292 303
    }
293 304

@@ -18,6 +18,22 @@
Loading
18 18
import net.sourceforge.kolmafia.request.StorageRequest;
19 19
20 20
public abstract class FamiliarManager {
21 +
  public static void changeFamiliar(int famId) {
22 +
    changeFamiliar(famId, true);
23 +
  }
24 +
25 +
  public static void changeFamiliar(int famId, boolean stealEquipment) {
26 +
    changeFamiliar(KoLCharacter.findFamiliar(famId), stealEquipment);
27 +
  }
28 +
29 +
  public static void changeFamiliar(FamiliarData familiar) {
30 +
    changeFamiliar(familiar, true);
31 +
  }
32 +
33 +
  public static void changeFamiliar(FamiliarData familiar, boolean stealEquipment) {
34 +
    RequestThread.postRequest(new FamiliarRequest(familiar, stealEquipment));
35 +
  }
36 +
21 37
  public static void equipAllFamiliars() {
22 38
    KoLmafia.updateDisplay("Equipping familiars...");
23 39

@@ -14,6 +14,7 @@
Loading
14 14
import net.sourceforge.kolmafia.persistence.PocketDatabase.Pocket;
15 15
import net.sourceforge.kolmafia.preferences.Preferences;
16 16
import net.sourceforge.kolmafia.session.ClanManager;
17 +
import net.sourceforge.kolmafia.session.FamiliarManager;
17 18
import net.sourceforge.kolmafia.session.InventoryManager;
18 19
import net.sourceforge.kolmafia.session.ResultProcessor;
19 20
import net.sourceforge.kolmafia.utilities.StringUtilities;
@@ -43,8 +44,7 @@
Loading
43 44
      // This should never happen if you don't have an Intergnat
44 45
      // unless you are manually setting demonName12 to break things
45 46
      currentFam = KoLCharacter.getFamiliar();
46 -
      RequestThread.postRequest(
47 -
          new FamiliarRequest(KoLCharacter.findFamiliar(FamiliarPool.INTERGNAT)));
47 +
      FamiliarManager.changeFamiliar(FamiliarPool.INTERGNAT, false);
48 48
    }
49 49
50 50
    KoLmafia.updateDisplay("Summoning " + this.demon + "...");

@@ -5,10 +5,9 @@
Loading
5 5
import net.sourceforge.kolmafia.KoLConstants.MafiaState;
6 6
import net.sourceforge.kolmafia.KoLmafia;
7 7
import net.sourceforge.kolmafia.RequestLogger;
8 -
import net.sourceforge.kolmafia.RequestThread;
9 8
import net.sourceforge.kolmafia.objectpool.FamiliarPool;
10 9
import net.sourceforge.kolmafia.persistence.ItemDatabase;
11 -
import net.sourceforge.kolmafia.request.FamiliarRequest;
10 +
import net.sourceforge.kolmafia.session.FamiliarManager;
12 11
import net.sourceforge.kolmafia.session.HeistManager;
13 12
14 13
public class HeistCommand extends AbstractCommand {
@@ -24,9 +23,7 @@
Loading
24 23
    }
25 24
26 25
    FamiliarData current = KoLCharacter.getFamiliar();
27 -
28 -
    RequestThread.postRequest(
29 -
        new FamiliarRequest(KoLCharacter.findFamiliar(FamiliarPool.CAT_BURGLAR)));
26 +
    FamiliarManager.changeFamiliar(FamiliarPool.CAT_BURGLAR, false);
30 27
31 28
    parameter = parameter.trim();
32 29
@@ -35,7 +32,7 @@
Loading
35 32
    } else {
36 33
      heistItem(parameter);
37 34
    }
38 -
    RequestThread.postRequest(new FamiliarRequest(current));
35 +
    FamiliarManager.changeFamiliar(current);
39 36
  }
40 37
41 38
  private void showAllItems() {

@@ -6246,8 +6246,7 @@
Loading
6246 6246
      throw controller.runtimeException("You don't have a Cat Burglar");
6247 6247
    }
6248 6248
    FamiliarData current = KoLCharacter.getFamiliar();
6249 -
    RequestThread.postRequest(
6250 -
        new FamiliarRequest(KoLCharacter.findFamiliar(FamiliarPool.CAT_BURGLAR)));
6249 +
    FamiliarManager.changeFamiliar(FamiliarPool.CAT_BURGLAR, false);
6251 6250
6252 6251
    MapValue returnValue = new MapValue(HeistType);
6253 6252
    var heistData = new HeistManager().getHeistTargets();
@@ -6262,7 +6261,7 @@
Loading
6262 6261
      returnValue.aset(DataTypes.makeMonsterValue(monster.id, false), value);
6263 6262
    }
6264 6263
6265 -
    RequestThread.postRequest(new FamiliarRequest(current));
6264 +
    FamiliarManager.changeFamiliar(current);
6266 6265
    return returnValue;
6267 6266
  }
6268 6267
@@ -6271,13 +6270,12 @@
Loading
6271 6270
      throw controller.runtimeException("You don't have a Cat Burglar");
6272 6271
    }
6273 6272
    FamiliarData current = KoLCharacter.getFamiliar();
6274 -
    RequestThread.postRequest(
6275 -
        new FamiliarRequest(KoLCharacter.findFamiliar(FamiliarPool.CAT_BURGLAR)));
6273 +
    FamiliarManager.changeFamiliar(FamiliarPool.CAT_BURGLAR, false);
6276 6274
6277 6275
    int itemId = (int) item.intValue();
6278 6276
    var heisted = new HeistManager().heist(itemId);
6279 6277
6280 -
    RequestThread.postRequest(new FamiliarRequest(current));
6278 +
    FamiliarManager.changeFamiliar(current);
6281 6279
    return DataTypes.makeBooleanValue(heisted);
6282 6280
  }
6283 6281

@@ -29,7 +29,6 @@
Loading
29 29
import net.sourceforge.kolmafia.request.ClosetRequest;
30 30
import net.sourceforge.kolmafia.request.CoinMasterRequest;
31 31
import net.sourceforge.kolmafia.request.EquipmentRequest;
32 -
import net.sourceforge.kolmafia.request.FamiliarRequest;
33 32
import net.sourceforge.kolmafia.request.GenericRequest;
34 33
import net.sourceforge.kolmafia.request.GenieRequest;
35 34
import net.sourceforge.kolmafia.request.HermitRequest;
@@ -799,10 +798,10 @@
Loading
799 798
800 799
    FamiliarData currentFam = KoLCharacter.getFamiliar();
801 800
802 -
    RequestThread.postRequest(new FamiliarRequest(jellyfish));
801 +
    FamiliarManager.changeFamiliar(jellyfish, false);
803 802
    RequestThread.postRequest(new PlaceRequest("thesea", "thesea_left2", false));
804 803
    RequestThread.postRequest(new GenericRequest("choice.php?whichchoice=1219&option=1"));
805 -
    RequestThread.postRequest(new FamiliarRequest(currentFam));
804 +
    FamiliarManager.changeFamiliar(currentFam);
806 805
807 806
    KoLmafia.forceContinue();
808 807
  }
Files Complexity Coverage
lib 14.24% 12.33%
src/net/sourceforge/kolmafia 13.04% 18.23%
Project Totals (1019 files) 13.06% 18.12%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading