Regarding a piece state of mind after losing money because you lost a court-case, refer to the Gemara in Sanhedrin.
There was a certain man who was saying as he walked: With regard to one who goes from the court, and his cloak has been taken from him in the course of the proceedings, i.e., he lost all his money due to a ruling against him, let him sing a song and go happily on the way. Although he lost the case, he has benefited from justice being served. Shmuel said to Rav Yehuda: A verse is written with regard to Yitro’s advice for judiciary reforms that conveys the message of this aphorism: “And all these people shall also go to their place in peace” (Exodus 18:23). If justice is served, all the litigants, not only those who emerge victorious, can leave in peace. (Sanhedrin 7a)
See also Sanhedrin 25a:
Rav Idi bar Avin says: One who is suspected of selling tereifot to others has no remedy to restore his fitness to bear witness until he goes to a locale where they do not recognize him and returns a lost item of substantial value that he finds, or removes his own tereifa meat of significant value from his possession. These actions demonstrate that he has repented, as he is willing to lose money for a mitzva. By contrast, if he does so in a place where he is recognized his fitness in not reinstated based on these actions, as perhaps he performed them only in order to be reinstated.