Trying to find a name in a table

Hey, I’m making a card game & made a list of the cards in a table. I thought I could run through the list and match the card I want with the correct info in the table, but i’m getting the wrong info. I place Captain in, but it giving me the info for the first one in the list.
here main:

Table CardTable;
TableRow CardRow;
ArrayList<Card> card = new ArrayList<Card>();

void setup(){
  size(600,600);
  CardTable = loadTable("card.csv","header");
  card.add(new Card("Captain"));// here i create the card
}
void draw(){
  background(0);
  for (int i = card.size()-1; i >= 0; i--){
    Card c = card.get(i);
    c.show();
  }
}

here card

class Card{
  int x,y,life,attack,common,row;
  String Name,Race,n;
  
  Card(String Name){
    this.Name = Name;
    for (int i = 0; i < 57; i++){
      CardRow = CardTable.getRow(i);
      n = CardRow.getString("Name");
      if (n == Name){
        row = i;
      }
    }
    get();
  }// card
  
  void get(){
    CardRow = CardTable.getRow(row);
    life = CardRow.getInt("Life");
    attack = CardRow.getInt("Attack");
    Race = CardRow.getString("Race");
    common = CardRow.getInt("Common");
  }
  
  void show(){
    textSize(10);
    text("Name: " + Name, 5, 10);
    text("Race: " + Race, 5, 20);
    text("Attack: " + attack, 5, 30);
    text("Life: " + life, 5, 40);
    text("Common: " + common, 5, 50);
    text("Row: " + row, 5, 60);
  }
}

the first 4 things in the table are

Name,Race,Attack,Life,Common
Guard,Human,1,3,1
Sentinel,Human,2,7,2
Captain,Human,2,9,3

1 Like

https://processing.org/reference/String_equals_.html

//      if (n == Name){
      if (n.equals(Name)){

anyhow check on
https://processing.org/reference/Table_findRow_.html
it does the search job for you.

2 Likes

Thanks, that fixed my problem.